I’ve been doing some “printf’ing”.
Sorry about my slowness here. I did not think of editing the imported files before.
Some things I have found:
- In the documentation,
mapRequestToAsset is recommended to alter the URL, after which you make a new Request with the altered URL. BUT
Request() encodes its URL, so decoding in mapRequestToAssset is futile.
- I then decoded the URL in kv-asset-handler itself. Now, in the previewer and playground, things work perfectly. However, on the live worker the non-latin language pages load their content for a split second, after which they switch to a botched up mixture of the post and a 404 page. (This may be due to caching on my end. I’ll test some more. EDIT: YES, see EDIT2 below.)
- When I used encoded file names instead of decoded file names, the reason I still got the error was because the script searches for the encoded file names in upper case (all caps), while they are stored in lower case. I do not know why it would search for the upper case path, since the link goes to the lowercase version. Maybe this is even the issue behind the overall problem I’m having. Again, I edited kv-asset-handler to make the pathKey lower case.
However, this now results in the page loading for a split second, and then going white.
EDIT2: The weird results after decoding the URL before were due to browser caching on my end. So things now work by using decoded keys and decoding the pathKey in kv-asset-handler.
@sklabnik, do any of these things sound like bugs? On one hand there is the fact that things only work if I decode the pathKey (if I use decoded filenames/keys), and on the other hand, if I use encoded filenames/keys, kv-asset-handler for some reason looks for the key in all caps, while it is stored in lowercase.