1 | ;
|
2 |
|
3 | const URL = require('url');
|
4 |
|
5 | const path = require('path');
|
6 | /**
|
7 | * Joins a path onto a URL, and normalizes Windows paths
|
8 | * e.g. from \path\to\res.js to /path/to/res.js.
|
9 | */
|
10 |
|
11 |
|
12 | module.exports = function (publicURL, assetPath) {
|
13 | const url = URL.parse(publicURL, false, true);
|
14 | const assetUrl = URL.parse(assetPath);
|
15 | url.pathname = path.posix.join(url.pathname, assetUrl.pathname);
|
16 | url.search = assetUrl.search;
|
17 | url.hash = assetUrl.hash;
|
18 | return URL.format(url);
|
19 | }; |
\ | No newline at end of file |