1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.getBundleURL = exports.getBaseURL = void 0;
|
5 | let bundleURL;
|
6 | function getBundleURLCached() {
|
7 | if (!bundleURL) {
|
8 | bundleURL = getBundleURL();
|
9 | }
|
10 | return bundleURL;
|
11 | }
|
12 | exports.getBundleURL = getBundleURLCached;
|
13 | function getBundleURL() {
|
14 |
|
15 | try {
|
16 | throw new Error;
|
17 | }
|
18 | catch (err) {
|
19 | const matches = ("" + err.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);
|
20 | if (matches) {
|
21 | return getBaseURL(matches[0]);
|
22 | }
|
23 | }
|
24 | return "/";
|
25 | }
|
26 | function getBaseURL(url) {
|
27 | return ("" + url).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)?\/[^/]+(?:\?.*)?$/, '$1') + '/';
|
28 | }
|
29 | exports.getBaseURL = getBaseURL;
|