hensei-web/node_modules/parcel-bundler/lib/utils/urlJoin.js
2020-09-11 06:44:42 -07:00

19 lines
No EOL
486 B
JavaScript

"use strict";
const URL = require('url');
const path = require('path');
/**
* Joins a path onto a URL, and normalizes Windows paths
* e.g. from \path\to\res.js to /path/to/res.js.
*/
module.exports = function (publicURL, assetPath) {
const url = URL.parse(publicURL, false, true);
const assetUrl = URL.parse(assetPath);
url.pathname = path.posix.join(url.pathname, assetUrl.pathname);
url.search = assetUrl.search;
url.hash = assetUrl.hash;
return URL.format(url);
};