UNPKG

245 BPlain TextView Raw
1export function getURL(base: string, url: string): string {
2 if (!base?.startsWith('http://') && !base?.startsWith('https://')) {
3 base = 'http://' + base;
4 }
5 try {
6 return new URL(url, base).href;
7 } catch (e) {
8 return '';
9 }
10}