diff --git a/lib/config.js b/lib/config.js index 54b043a7..81ff88e3 100644 --- a/lib/config.js +++ b/lib/config.js @@ -2,7 +2,7 @@ import BLOG from '@/blog.config' import { useGlobal } from './global' -import { deepClone, isUrl } from './utils' +import { deepClone, isUrlLikePath } from './utils' /** * 读取配置顺序 @@ -146,7 +146,7 @@ export const convertVal = val => { } // 检测是否为 URL - if (isUrl(val)) { + if (isUrlLikePath(val)) { return val } diff --git a/lib/utils/index.js b/lib/utils/index.js index bfef0f46..b0e0c77e 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -80,16 +80,13 @@ export function convertUrlStartWithOneSlash(str) { } /** - * 是否是一个相对或绝对路径的ur类 - * @param {*} str - * @returns + * 判断是否是一个“URL 样式”的路径(内部或外部) + * 内部如 /about,外部如 http://xxx.com + * @param str + * @returns {boolean} */ -export function isUrl(str) { - if (!str) { - return false - } - - return str?.indexOf('/') === 0 || isHttpLink(str) +export function isUrlLikePath(str) { + return typeof str === 'string' && (str.startsWith('/') || isHttpLink(str)) } /**