Files: ccc34dfd351fd863de680736e90b24f449a31a13 / lib / util.js
431 bytesRaw
1 | const URL = (typeof window === 'undefined') ? require('url-parse') : window.URL; |
2 | |
3 | exports.toArchiveOrigin = function toArchiveOrigin (v) { |
4 | if (v) { |
5 | if (typeof v.getRecordOrigin === 'function') { |
6 | return v.getRecordOrigin(); |
7 | } |
8 | |
9 | if (typeof v.url === 'string') { |
10 | v = v.url; |
11 | } |
12 | |
13 | const urlp = new URL(v); |
14 | |
15 | return urlp.protocol + '//' + urlp.hostname; |
16 | } |
17 | |
18 | throw new Error('Not a valid archive'); |
19 | }; |
Built with git-ssb-web