.
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
// Adapted from React's sanitizeURL function found here: https://github.com/facebook/react/blob/b565373afd0cc1988497e1107106e851e8cfb261/packages/react-dom-bindings/src/shared/sanitizeURL.js
|
||||
// A javascript: URL can contain leading C0 control or \u0020 SPACE,
|
||||
// and any newline or tab are filtered out as if they're not part of the URL.
|
||||
// https://url.spec.whatwg.org/#url-parsing
|
||||
// Tab or newline are defined as \r\n\t:
|
||||
// https://infra.spec.whatwg.org/#ascii-tab-or-newline
|
||||
// A C0 control is a code point in the range \u0000 NULL to \u001F
|
||||
// INFORMATION SEPARATOR ONE, inclusive:
|
||||
// https://infra.spec.whatwg.org/#c0-control-or-space
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "isJavaScriptURLString", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return isJavaScriptURLString;
|
||||
}
|
||||
});
|
||||
const isJavaScriptProtocol = // eslint-disable-next-line no-control-regex
|
||||
/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;
|
||||
function isJavaScriptURLString(url) {
|
||||
return isJavaScriptProtocol.test('' + url);
|
||||
}
|
||||
|
||||
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
||||
Object.defineProperty(exports.default, '__esModule', { value: true });
|
||||
Object.assign(exports.default, exports);
|
||||
module.exports = exports.default;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=javascript-url.js.map
|
||||
Reference in New Issue
Block a user