|
5 | 5 | import { fileURLToPath } from 'url'; |
6 | 6 | import path from 'path'; |
7 | 7 |
|
8 | | -import { urlToRequest, interpolateName, isUrlRequest } from 'loader-utils'; |
| 8 | +import { urlToRequest, interpolateName } from 'loader-utils'; |
9 | 9 | import normalizePath from 'normalize-path'; |
10 | 10 | import cssesc from 'cssesc'; |
11 | 11 | import modulesValues from 'postcss-modules-values'; |
@@ -87,7 +87,7 @@ function requestify(url, rootContext) { |
87 | 87 | return fileURLToPath(url); |
88 | 88 | } |
89 | 89 |
|
90 | | - return mayBeServerRelativeUrl(url) |
| 90 | + return url.charAt(0) === '/' |
91 | 91 | ? urlToRequest(url, rootContext) |
92 | 92 | : urlToRequest(url); |
93 | 93 | } |
@@ -508,31 +508,33 @@ async function resolveRequests(resolve, context, possibleRequests) { |
508 | 508 | }); |
509 | 509 | } |
510 | 510 |
|
511 | | -/* |
512 | | - * May be url is server-relative url, but not //example.com |
513 | | - * */ |
514 | | -function mayBeServerRelativeUrl(url) { |
515 | | - if (url.charAt(0) === '/' && !/^\/\//.test(url)) { |
516 | | - return true; |
517 | | - } |
518 | | - |
519 | | - return false; |
520 | | -} |
521 | | - |
522 | 511 | function isUrlRequestable(url) { |
| 512 | + // Windows absolute paths |
523 | 513 | if (matchNativeWin32Path.test(url)) { |
524 | 514 | return false; |
525 | 515 | } |
526 | 516 |
|
527 | | - if (mayBeServerRelativeUrl(url)) { |
528 | | - return true; |
| 517 | + // Protocol-relative URLs |
| 518 | + if (/^\/\//.test(url)) { |
| 519 | + return false; |
529 | 520 | } |
530 | 521 |
|
| 522 | + // `file:` protocol |
531 | 523 | if (/^file:/i.test(url)) { |
532 | 524 | return true; |
533 | 525 | } |
534 | 526 |
|
535 | | - return isUrlRequest(url); |
| 527 | + // Absolute URLs |
| 528 | + if (/^[a-z][a-z0-9+.-]*:/i.test(url)) { |
| 529 | + return false; |
| 530 | + } |
| 531 | + |
| 532 | + // `#` URLs |
| 533 | + if (/^#/.test(url)) { |
| 534 | + return false; |
| 535 | + } |
| 536 | + |
| 537 | + return true; |
536 | 538 | } |
537 | 539 |
|
538 | 540 | function sort(a, b) { |
|
0 commit comments