1 | "use strict";
|
2 |
|
3 | const trimSlashes = part => part.replace(/(^\/)|(\/$)/g, ``);
|
4 |
|
5 | const isURL = possibleUrl => [`http://`, `https://`, `//`].some(expr => possibleUrl.startsWith(expr));
|
6 |
|
7 | module.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 |
|
\ | No newline at end of file |