Son CV dans un terminal web en Javascript!
https://terminal-cv.gregandev.fr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
49 lines
1.0 KiB
"use strict";
|
|
|
|
var bundleURL = {};
|
|
|
|
function getBundleURLCached(id) {
|
|
var value = bundleURL[id];
|
|
|
|
if (!value) {
|
|
value = getBundleURL();
|
|
bundleURL[id] = value;
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
function getBundleURL() {
|
|
try {
|
|
throw new Error();
|
|
} catch (err) {
|
|
var matches = ('' + err.stack).match(/(https?|file|ftp):\/\/[^)\n]+/g);
|
|
|
|
if (matches) {
|
|
// The first two stack frames will be this function and getBundleURLCached.
|
|
// Use the 3rd one, which will be a runtime in the original bundle.
|
|
return getBaseURL(matches[2]);
|
|
}
|
|
}
|
|
|
|
return '/';
|
|
}
|
|
|
|
function getBaseURL(url) {
|
|
return ('' + url).replace(/^((?:https?|file|ftp):\/\/.+)\/[^/]+$/, '$1') + '/';
|
|
} // TODO: Replace uses with `new URL(url).origin` when ie11 is no longer supported.
|
|
|
|
|
|
function getOrigin(url) {
|
|
var matches = ('' + url).match(/(https?|file|ftp):\/\/[^/]+/);
|
|
|
|
if (!matches) {
|
|
throw new Error('Origin not found');
|
|
}
|
|
|
|
return matches[0];
|
|
}
|
|
|
|
exports.getBundleURL = getBundleURLCached;
|
|
exports.getBaseURL = getBaseURL;
|
|
exports.getOrigin = getOrigin; |