Commit f21d293
committed
Fix: Allow absolute URLs as paths, e.g. for load()
When using protobuf.js in a browser, it's useful to be able to load
proto files from other origins. But currently, path.normalize() mangles
URLs by removing the second slash after the scheme (e.g.
"https://example.com/" becomes "https:/example.com").
Fix that issue, and better integrate the existing UNC support, by
introducing a new path.absolutePrefix() function that checks for all the
various prefixes that indicate a path is absolute and returns the one it
finds (if any). By including both slashes in the return value for URLs,
we exclude them from the normalization logic.
Note that this almost certainly still isn't perfect, as URLs, UNC paths,
and even Windows drive letters are all quite complex. But I don't have
the time or project context to make a major change here.1 parent 00d5f1a commit f21d293
File tree
5 files changed
+69
-12
lines changed- lib/path
- tests
5 files changed
+69
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2423 | 2423 | | |
2424 | 2424 | | |
2425 | 2425 | | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
2426 | 2433 | | |
2427 | 2434 | | |
2428 | 2435 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
1 | 8 | | |
2 | 9 | | |
3 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
10 | 35 | | |
11 | 36 | | |
12 | 37 | | |
13 | 38 | | |
14 | 39 | | |
15 | 40 | | |
16 | 41 | | |
17 | | - | |
| 42 | + | |
18 | 43 | | |
19 | 44 | | |
20 | 45 | | |
| |||
24 | 49 | | |
25 | 50 | | |
26 | 51 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
32 | 59 | | |
33 | 60 | | |
34 | 61 | | |
35 | 62 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 63 | + | |
41 | 64 | | |
42 | 65 | | |
43 | 66 | | |
| |||
51 | 74 | | |
52 | 75 | | |
53 | 76 | | |
54 | | - | |
| 77 | + | |
55 | 78 | | |
56 | 79 | | |
57 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
64 | 81 | | |
65 | 82 | | |
66 | 83 | | |
| |||
0 commit comments