aswi2020vldc-gitlab/templetes/node_modules/is-absolute-url/index.js @ 56f6c6df
1 | 3a515b92 | cagy | 'use strict'; |
---|---|---|---|
2 | |||
3 | module.exports = url => { |
||
4 | if (typeof url !== 'string') { |
||
5 | throw new TypeError(`Expected a \`string\`, got \`${typeof url}\``); |
||
6 | }
|
||
7 | |||
8 | // Don't match Windows paths `c:\`
|
||
9 | if (/^[a-zA-Z]:\\/.test(url)) { |
||
10 | return false; |
||
11 | }
|
||
12 | |||
13 | // Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
|
||
14 | // Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
|
||
15 | return /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url); |
||
16 | };
|