Skip to content

Commit 2952eed

Browse files
committed
Vendor is-absolute-url
1 parent 35206c3 commit 2952eed

File tree

4 files changed

+19
-31
lines changed

4 files changed

+19
-31
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"plugins": ["@babel/plugin-transform-runtime"],
44
"env": {
55
"test": {
6-
// "plugins": ["@babel/plugin-transform-class-properties"]
6+
"plugins": ["@babel/plugin-transform-class-properties"]
77
}
88
}
99
}

package-lock.json

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@plotly/dash-component-plugins": "^1.2.3",
3333
"classnames": "^2.5.1",
3434
"fast-isnumeric": "^1.1.4",
35-
"is-absolute-url": "^4.0.1",
3635
"prop-types": "^15.8.1",
3736
"ramda": "^0.30.1",
3837
"react": "^18.3.1",

src/private/Link.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
/* global window:true */
2-
3-
import isAbsoluteUrl from 'is-absolute-url';
4-
52
import PropTypes from 'prop-types';
63
import React, {Component} from 'react';
74

8-
/* event polyfill for IE https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent */
9-
function CustomEvent(event, params) {
10-
// eslint-disable-next-line no-param-reassign
11-
params = params || {
12-
bubbles: false,
13-
cancelable: false,
14-
// eslint-disable-next-line no-undefined
15-
detail: undefined
16-
};
17-
const evt = document.createEvent('CustomEvent');
18-
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
19-
return evt;
5+
// absolute URL check vendored from is-absolute-url
6+
// Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
7+
// Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
8+
const ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
9+
10+
// Windows paths like `c:\`
11+
const WINDOWS_PATH_REGEX = /^[a-zA-Z]:\\/;
12+
13+
function isAbsoluteUrl(url) {
14+
if (typeof url !== 'string') {
15+
throw new TypeError(`Expected a \`string\`, got \`${typeof url}\``);
16+
}
17+
18+
if (WINDOWS_PATH_REGEX.test(url)) {
19+
return false;
20+
}
21+
22+
return ABSOLUTE_URL_REGEX.test(url);
2023
}
21-
CustomEvent.prototype = window.Event.prototype;
2224

2325
function isExternalLink(external_link, href) {
2426
if (typeof external_link === 'undefined' || external_link === null) {

0 commit comments

Comments
 (0)