Skip to content
New issue

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

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

Already on GitHub? # 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\astro@4.12.2_@types+node@20.14.12_lightningcss@1.25.1_sass@1.77.8_stylus@0.63.0_terser@5.31.3_typescript@5.5.4\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.

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

No branches or pull requests

2 participants