@umijs/route-utils
Advanced tools
Comparing version 1.0.35 to 1.0.36
@@ -8,5 +8,14 @@ import isEqual from 'fast-deep-equal/es6/index'; | ||
} | ||
/* eslint no-useless-escape:0 import/prefer-default-export:0 */ | ||
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; | ||
export const isUrl = (path) => reg.test(path); | ||
export const isUrl = (path) => { | ||
if (!path.startsWith('http')) { | ||
return false; | ||
} | ||
try { | ||
const url = new URL(path); | ||
return !!url; | ||
} | ||
catch (error) { | ||
return false; | ||
} | ||
}; | ||
export const getKeyByPath = (item) => { | ||
@@ -13,0 +22,0 @@ const { path } = item; |
@@ -68,7 +68,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
} | ||
/* eslint no-useless-escape:0 import/prefer-default-export:0 */ | ||
export var isUrl = function isUrl(path) { | ||
if (!path.startsWith('http')) { | ||
return false; | ||
} | ||
var reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; | ||
export var isUrl = function isUrl(path) { | ||
return reg.test(path); | ||
try { | ||
var url = new URL(path); | ||
return !!url; | ||
} catch (error) { | ||
return false; | ||
} | ||
}; | ||
@@ -75,0 +81,0 @@ export var getKeyByPath = function getKeyByPath(item) { |
@@ -82,9 +82,14 @@ "use strict"; | ||
} | ||
/* eslint no-useless-escape:0 import/prefer-default-export:0 */ | ||
var isUrl = function isUrl(path) { | ||
if (!path.startsWith('http')) { | ||
return false; | ||
} | ||
var reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; | ||
var isUrl = function isUrl(path) { | ||
return reg.test(path); | ||
try { | ||
var url = new URL(path); | ||
return !!url; | ||
} catch (error) { | ||
return false; | ||
} | ||
}; | ||
@@ -91,0 +96,0 @@ |
{ | ||
"name": "@umijs/route-utils", | ||
"version": "1.0.35", | ||
"version": "1.0.36", | ||
"description": "Quickly process the routing of umi", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2255
118030