From b2cca7f34c477625a80733095a331e5caef0dad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 1 Jul 2019 10:58:23 +0800 Subject: [PATCH] remove "path.indexOf(/) === 0" fix #40 --- src/utils/utils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 41ef8303..aa73c8fa 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,8 +1,6 @@ /* 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 function isUrl(path: string): boolean { - return reg.test(path) || path.indexOf('/') === 0; -} +export const isUrl = (path: string): boolean => reg.test(path); export const isBrowser = () => typeof window !== 'undefined';