Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a category contains #, problems occur during the build process #199

Open
PIXELHIZE opened this issue Oct 3, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@PIXELHIZE
Copy link

While I was making a post using these sources, I accidentally found out that if a category contains #, an error occurs during the birch.
I've been looking for a way to fix this error. My conclusion is that in the path node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]\node_modules\astro\dist\core\fs\index.js, in the

function removeEmptyDirs(root) {
  const dir = fileURLToPath(root);
  if (!fs.statSync(dir).isDirectory()) return;
  let files = fs.readdirSync(dir);
  if (files.length > 0) {
    files.map((file) => {
      const url = new URL(`./${file}`, appendForwardSlash(root.toString()));
      removeEmptyDirs(url);
    });
    files = fs.readdirSync(dir);
  }
  if (files.length === 0) {
    fs.rmdirSync(dir);
  }
}

is modified as follows.

function removeEmptyDirs(root) {
  const dir = fileURLToPath(root);
  if (!fs.statSync(dir).isDirectory()) return;
  let files = fs.readdirSync(dir);
  if (files.length > 0) {
    files.map((file) => {
      // fix
      const encodedFile = encodeURIComponent(file);
      const url = new URL(`./${encodedFile}`, appendForwardSlash(root.toString()));
      removeEmptyDirs(url);
    });
    files = fs.readdirSync(dir);
  }
  if (files.length === 0) {
    fs.rmdirSync(dir);
  }
}

Yes, that's right. As you can see from the path, to fix that error, you need to upload node_modules along with the site build. This is a waste of resources and a lot of work. I need your help.

@saicaca saicaca added the bug Something isn't working label Oct 22, 2024
@saicaca
Copy link
Owner

saicaca commented Oct 22, 2024

Currently, tags and categories cannot contain URL reserved characters like # / ?. I tried encoding the string but it didn't help since Astro automatically decodes the path during the build process.

The good news is that Astro 5.0 will remove the decoding, so I will try to fix this when 5.0 is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants