mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-20 07:26:46 +00:00
refactor(utils): rename and improve isUrl to isUrlLikePath
- Rename isUrl function to isUrlLikePath for better clarity - Simplify function logic and add type checking - Update all references to use the new function name - Improve function documentation and parameter typing
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user