Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Add support for non ascii path #100

Merged
merged 2 commits into from
Jun 5, 2020

Conversation

SukkaW
Copy link
Contributor

@SukkaW SukkaW commented Jun 4, 2020

What is the PR for?

The PR is trying to fix #99

What happened?

Well, wrangler publish will store the original path & filename inside Workers KV, just like the screenshot shows:

However, new URL will encode path by default:

const url = new URL('https://example.com/你好/');
url.href;
// "https://example.com/%E4%BD%A0%E5%A5%BD/"
url.pathname;
// "/%E4%BD%A0%E5%A5%BD/"

Then?

Since I am a Cloudflare Enterprise customer, the first thing I do is to open a ticket at Cloudflare Support. Then the Technical Support Engineer told me it is a known issue and no ETA for fixes. Then I asked if any workarounds could be provided and received "the workaround that I am aware of which is not ideal, is to migrate away pathes".

Well, I can fix the issue myself.

Instead of letting wrangler-cli encoding filename, I create this PR to let kv-asset-handler handle encoded URL by decoding path before handling.

Is the changes tested?

At least I have added a test case.

@SukkaW SukkaW mentioned this pull request Jun 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non ASCII path returned 404
2 participants