UNPKG

581 BJavaScriptView Raw
1"use strict";
2
3const trimSlashes = part => part.replace(/(^\/)|(\/$)/g, ``);
4
5const isURL = possibleUrl => [`http://`, `https://`, `//`].some(expr => possibleUrl.startsWith(expr));
6
7module.exports = function getPublicPath({
8 assetPrefix,
9 pathPrefix,
10 prefixPaths
11}) {
12 if (prefixPaths && (assetPrefix || pathPrefix)) {
13 const normalized = [assetPrefix, pathPrefix].filter(part => part && part.length > 0).map(part => trimSlashes(part)).join(`/`);
14 return isURL(normalized) ? normalized : `/${normalized}`;
15 }
16
17 return ``;
18};
19//# sourceMappingURL=get-public-path.js.map
\No newline at end of file