cloudflare / cloudflare/workerd

🐛/✨ Bug Report/Feature Request — Improve/fix inconvenient path quirks in module fallback service (because of leading `/`s)

Open
#2,808 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

As I've been working with the module fallback service I've found three quirks that I had to workaround (in this [patch function](https://github.com/flarelabs-net/vite-environment-providers/blob/01247db8e566fd1fdb5b66a95de37bf27b29bda2/packages/vite-environment-provider-cloudflare/src/moduleFallback.ts#L180-L265)).

These are all related to leading `/`s in paths and I believe could/should be addressed in workerd itself without consumers of the service having to deal with them.

The quirks are:
- the referred/specifier paths that workerd provides to the service always start with `/`, this can be problematic in windows where absolute paths do not start with `/` ([patch](https://github.com/flarelabs-net/vite-environment-providers/blob/01247db8e566fd1fdb5b66a95de37bf27b29bda2/packages/vite-environment-provider-cloudflare/src/moduleFallback.ts#L196-L210))
- when returning a redirection (301) result, such needs to start with `/`, again this is problematic in windows where absolute paths do not start with `/` ([patch](https://github.com/flarelabs-net/vite-environment-providers/blob/01247db8e566fd1fdb5b66a95de37bf27b29bda2/packages/vite-environment-provider-cloudflare/src/moduleFallback.ts#L218-L245))
- when returning a module (200) result, the name of the module must not include `/`, that in my opinion is a bizzare/confusing behavior because in all other cases workerd includes leading `/`s but in this case it actually refuses paths that start with `/` ([patch](https://github.com/flarelabs-net/vite-environment-providers/blob/01247db8e566fd1fdb5b66a95de37bf27b29bda2/packages/vite-environment-provider-cloudflare/src/moduleFallback.ts#L247-L261))

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.