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

Deno deploy preset doesn't decodeURIComponent the file URL before reading from Deno.readFile #1493

Closed
nksaraf opened this issue Jul 27, 2023 · 0 comments · Fixed by #1494
Closed
Labels
bug Something isn't working preset:deno

Comments

@nksaraf
Copy link
Contributor

nksaraf commented Jul 27, 2023

Environment

Node: v18.15.0
Nitropack: 2.5.2

Reproduction

Couldn't create a great repro in time but I have debugged the issue below and made a PR (to compensate lol)

Screenshot 2023-07-27 at 4 20 50 PM

Describe the bug

When the browser requests a static asset: eg. /fonts/cera/Cera Pro.otf, it goes to readAsset in Deno where this happens

function readAsset (id) {
  // https://deno.com/deploy/docs/serve-static-assets
  const path = '.' + new URL(`../public${id}`, 'file://').pathname;
  return Deno.readFile(path);
}

This tries to read ./fonts/cera/Cera%20Pro.otf from the file system which ofcourse doesn't exist. We need to decodeURIComponent the pathname before using it to read the file.

Additional context

No response

Logs

No response

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

Successfully merging a pull request may close this issue.

2 participants