question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

URLs with encoded characters not handled properly.

See original GitHub issue

If I have an asset with a filename test file.jpg the corresponding url is /test%20file.jpg, which is correct. However, getAssetFromKV tries to access it as test%20file.jpg which does not exist and fails.

the URL constructor converts all spaces not already encoded to %20 automatically, so a simplistic solution would be running decodeURI here after the url was already parsed with URL: https://github.com/cloudflare/kv-asset-handler/blob/d4fa91fae1806e30270dcc5f39f581ea37362a59/src/index.ts#L101

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
EverlastingBugstoppercommented, Feb 13, 2020

ooohhh - very interesting.

I’ve become so conditioned to respond to URL encoding issues with a recommendation to polyfill that I didn’t actually read your report.

Your diagnosis seems correct and using decodeURI should fix 👍

Happy to accept a PR or we can add this to our list of things to address.

0reactions
ispiveycommented, Jun 30, 2020

This will be fixed shortly in 0.0.11.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using URL encoding to handle special characters in a ...
In this article, we will walk through a scenario where exceptions are thrown if such a URI with special character is not handled...
Read more >
(Please) Stop Using Unsafe Characters in URLs
All unsafe characters must always be encoded within a URL. For example, the character # must be encoded within URLs even in systems...
Read more >
Which characters make a URL invalid? - Stack Overflow
Any of the reserved characters above can be legally used in a URI without encoding, either to serve their syntactic purpose or just...
Read more >
How fix a URL which breaks because of Unicode content
Throw that at something which is not able to handle full Unicode characters and it will fail. Instead, that URL can contain embedded...
Read more >
How should incorrectly encoded URLs be handled?
First things first, as @LazyOne said, the third-party URLs are not being properly generated, so the expectation is server to fail - as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found