Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
413 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | '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 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.