mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-31 15:10:11 +00:00
refactor: rename checkStartWithHttp to isHttpLink
- Update function name and implementation in utils/index.js - Replace all occurrences in getPageProperties.js, post.js, and BlogPostCard.js - Improve function documentation and use regex for better URL matching
This commit is contained in:
@@ -89,19 +89,16 @@ export function isUrl(str) {
|
||||
return false
|
||||
}
|
||||
|
||||
return str?.indexOf('/') === 0 || checkStartWithHttp(str)
|
||||
return str?.indexOf('/') === 0 || isHttpLink(str)
|
||||
}
|
||||
|
||||
// 检查是否外链
|
||||
export function checkStartWithHttp(str) {
|
||||
// 检查字符串是否包含http
|
||||
if (str?.indexOf('http:') === 0 || str?.indexOf('https:') === 0) {
|
||||
// 如果包含,找到http的位置
|
||||
return true
|
||||
} else {
|
||||
// 不包含
|
||||
return false
|
||||
}
|
||||
/**
|
||||
* 判断是否是 http(s) 开头的链接(外部网页)
|
||||
* @param str
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isHttpLink(str) {
|
||||
return typeof str === 'string' && /^https?:\/\//i.test(str)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user