frontend/.pnpm-store/v3/files/b4/9866fa4f114acd717f90830c1c8f2a87bfbde7d4ecfd9b2b2b7ec4a88557687746118a9171c7ed2e039c1117fed6c0e4c55246c447ef2deaacdaef64870388

16 lines
387 B
Plaintext

'use strict';
module.exports = (url, opts) => {
if (typeof url !== 'string') {
throw new TypeError(`Expected \`url\` to be of type \`string\`, got \`${typeof url}\``);
}
url = url.trim();
opts = Object.assign({https: false}, opts);
if (/^\.*\/|^(?!localhost)\w+:/.test(url)) {
return url;
}
return url.replace(/^(?!(?:\w+:)?\/\/)/, opts.https ? 'https://' : 'http://');
};