workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

fix: allow encoded characters in paths for workers + assets

Open emily-shen opened this issue 1 year ago • 2 comments

What this PR solves / how to test

Fixes #WC-2597 NB encodeFilePath is used here, in wrangler/experimental-assets.ts and miniflare, so this will be consolidated in a shared utils folder in workers-shared soontm

Author has addressed the following

  • Tests
    • [ ] TODO (before merge)
    • [x] Included
    • [ ] Not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • [ ] I don't know
    • [ ] Required / Maybe required
    • [x] Not required because: no relevant e2e tests
  • Changeset (Changeset guidelines)
    • [ ] TODO (before merge)
    • [ ] Included
    • [x] Not necessary because: not a public facing change
  • Public documentation
    • [ ] TODO (before merge)
    • [ ] Cloudflare docs PR(s):
    • [x] Not necessary because: unreleased feat

emily-shen avatar Aug 29 '24 14:08 emily-shen

⚠️ No Changeset found

Latest commit: 6a947cf833331a8bb89bf3052a4a95851dbb5031

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Aug 29 '24 14:08 changeset-bot[bot]

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10683487204/npm-package-wrangler-6598

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6598/npm-package-wrangler-6598

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10683487204/npm-package-wrangler-6598 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10683487204/npm-package-create-cloudflare-6598 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10683487204/npm-package-cloudflare-kv-asset-handler-6598
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10683487204/npm-package-miniflare-6598
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10683487204/npm-package-cloudflare-pages-shared-6598
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10683487204/npm-package-cloudflare-vitest-pool-workers-6598
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10683487204/npm-package-cloudflare-workers-editor-shared-6598
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10683487204/npm-package-cloudflare-workers-shared-6598

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240821.0
workerd 1.20240821.1 1.20240821.1
workerd --version 1.20240821.1 2024-08-21

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

github-actions[bot] avatar Aug 29 '24 14:08 github-actions[bot]

Sorry for going around in circles - going back to (basically) the original fix because:

  1. frameworks will request something like/about/%5Bpage%5D not %2Fabout%2F%5Bpage%5D and encoding each segment means we can handle this without asset worker having to do anything to an incoming request path.
  2. we want to allow filepaths with ? or # as long as theyre encoded and not doing encodeURIComponent on each segment doesn't do this properly.

emily-shen avatar Sep 03 '24 13:09 emily-shen

Sorry for going around in circles - going back to (basically) the original fix because:

  1. frameworks will request something like/about/%5Bpage%5D not %2Fabout%2F%5Bpage%5D and encoding each segment means we can handle this without asset worker having to do anything to an incoming request path.
  2. we want to allow filepaths with ? or # as long as theyre encoded and not doing encodeURIComponent on each segment doesn't do this properly.

I think this is the right decision 👍 Please document this reasoning in a comment with the (shared) encode/decode functions

RamIdeas avatar Sep 03 '24 13:09 RamIdeas