fix(vite): decode percent-encoded /ns/m request paths - #11483
Merged
NathanWalker merged 3 commits intoSep 30, 2026
Merged
Conversation
URL.pathname preserves percent-encoding, so device-encoded module URLs like /ns/m/app/demo/%5Bid%5D.tsrx reached the file lookup literally and 404'd while the raw-bracket spelling resolved. Decode the pathname- derived spec before candidate expansion (after the ?# strip so encoded %3F/%23 filename chars survive); the ?path= spec is already decoded by URLSearchParams and is left untouched to avoid double-decoding. Apply the same decode to the /ns/sfc path-style spec for bracketed .vue files. Fixes NativeScript#11455
|
View your CI Pipeline Execution ↗ for commit 99e04d3
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
NathanWalker
requested changes
Sep 30, 2026
decodeURI still decodes brackets and spaces but leaves reserved characters (%2F, %3F, %23) encoded, as Vite's transform middleware does.
NathanWalker
approved these changes
Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
What is the current behavior?
In dev-session (HTTP ESM) mode,
/ns/m/<path>module requests 404 when the device's HTTP layer percent-encodes the filename — e.g. file-based router params likeapp/demo/[id].tsrxfetched as/ns/m/.../%5Bid%5D.tsrx. The raw-bracket spelling resolves fine becauseURL.pathnamepreserves percent-encoding whilesearchParams.get('path')decodes it, so only path-style requests reached the file lookup still encoded.What is the new behavior?
createNsMRequestContextnow decodes the pathname-derived spec withdecodeURIComponentbefore candidate expansion, so encoded and raw spellings resolve the same on-disk module. Two details handled deliberately:[?#]strip, so filenames containing encoded?/#(%3F/%23) aren't mistaken for query delimiters.?path=value is already decoded once byURLSearchParams, and decoding it again would corrupt filenames containing a literal%. Malformed sequences fall back to the raw spec.The same class of bug existed in the
/ns/sfcpath-style spec (/ns/sfc/<path>.vue), which now decodes too — bracketed.vuefiles are the same dynamic-route scenario. Other handlers were audited:/ns/asm,/ns/sfc-meta,/ns/rt,/ns/entry,/ns/txn, and the deps-bundle/node-builtins routes either use?path=(already decoded), fixed prefixes, or already decode.Fixes #11455
Tests
Three regression specs in
websocket-ns-m-request.spec.ts: encoded-vs-raw spec equivalence, no double-decode of?path=, and%3F/%23surviving the query-strip. Full@nativescript/vitesuite: 1830 tests green.