Skip to content

Fix directory listing links broken by overzealous # encoding#57

Merged
parvardegr merged 3 commits into
mainfrom
copilot/fix-cannot-download-files
Jun 17, 2026
Merged

Fix directory listing links broken by overzealous # encoding#57
parvardegr merged 3 commits into
mainfrom
copilot/fix-cannot-download-files

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

The #%23 encoding in directory listing hrefs (from #50) also matched # inside HTML numeric entities like / (slash), turning them into &%2347; and producing 404s on every file link.

  • bin/app.js: Use negative lookbehind (?<!&)# to only encode # that isn't part of an HTML entity
  • test/test.js: Add assertion that &#47; entities are preserved; fix existing assertion to allow # inside entities
- const encoded = href.replace(/#/g, '%23');
+ const encoded = href.replace(/(?<!&)#/g, '%23');

Copilot AI added 2 commits June 17, 2026 04:47
The regex that encodes '#' as '%23' in href attributes was also matching
'#' inside HTML entities like '&#47;' (slash), turning them into '&%2347;'
and breaking all directory listing links. Use negative lookbehind (?<!&)
to skip '#' that is part of HTML numeric character references.

Closes #56
Copilot AI changed the title [WIP] Fix file download issue causing 404 error Fix directory listing links broken by overzealous # encoding Jun 17, 2026
Copilot AI requested a review from parvardegr June 17, 2026 04:49
@parvardegr parvardegr marked this pull request as ready for review June 17, 2026 04:50
@parvardegr parvardegr merged commit 72af2e8 into main Jun 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants