Commit bb2f8cb
fix(node-api): decode percent-encoded path before process.dlopen
`URL.pathname` is percent-encoded, but `process.dlopen` expects a filesystem
path. Any space in the package's path therefore reaches dlopen as "%20" and the
addon fails to load:
TypeError: dlopen(/Applications/My%20App.app/.../NativeScript, 0x0001):
tried: '.../My%20App.app/...' (no such file)
This breaks every packaged app whose path contains a space — for example an
.app installed to /Applications with a display name like "My App.app". It goes
unnoticed in development because the package normally resolves from a
node_modules path with no spaces, where decoding is a no-op; only a distributed
bundle exercises the failing path.
Wrap the resolved pathname in decodeURIComponent() at all three dlopen sites:
- packages/macos-node-api/index.mjs
- packages/macos-node-api/index.cjs
- packages/ios-node-api/index.js
Verified on macOS by copying packages/macos-node-api together with its built
NativeScript.framework into a directory whose name contains a space, then
importing it under Deno:
- before: dlopen fails with the %20 path shown above
- after: the addon loads and init() runs
Note: paths containing "#" or "?" are still mishandled, because the base URL is
built by string concatenation and those characters are parsed as fragment/query
delimiters. Spaces are by far the common case; a complete fix would resolve the
addon path without going through URL at all.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent f116e29 commit bb2f8cb
3 files changed
Lines changed: 20 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | | - | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | | - | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| |||
0 commit comments