mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-15 23:16:48 +00:00
{配置兼容性}
This commit is contained in:
@@ -81,8 +81,21 @@ export function convertUrlStartWithOneSlash(str) {
|
||||
return str
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是一个相对或绝对路径的ur类
|
||||
* @param {*} str
|
||||
* @returns
|
||||
*/
|
||||
export function isUrl(str) {
|
||||
if (!str) {
|
||||
return false
|
||||
}
|
||||
|
||||
return str?.indexOf('/') === 0 || checkStartWithHttp(str)
|
||||
}
|
||||
|
||||
// 检查是否外链
|
||||
export function checkContainHttp(str) {
|
||||
export function checkStartWithHttp(str) {
|
||||
// 检查字符串是否包含http
|
||||
if (str?.includes('http:') || str?.includes('https:')) {
|
||||
// 如果包含,找到http的位置
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 文章相关工具
|
||||
*/
|
||||
import { checkContainHttp } from '.'
|
||||
import { checkStartWithHttp } from '.'
|
||||
|
||||
/**
|
||||
* 获取文章的关联推荐文章列表,目前根据标签关联性筛选
|
||||
@@ -50,7 +50,7 @@ export function checkSlugHasNoSlash(row) {
|
||||
}
|
||||
return (
|
||||
(slug.match(/\//g) || []).length === 0 &&
|
||||
!checkContainHttp(slug) &&
|
||||
!checkStartWithHttp(slug) &&
|
||||
row.type.indexOf('Menu') < 0
|
||||
)
|
||||
}
|
||||
@@ -67,7 +67,7 @@ export function checkSlugHasOneSlash(row) {
|
||||
}
|
||||
return (
|
||||
(slug.match(/\//g) || []).length === 1 &&
|
||||
!checkContainHttp(slug) &&
|
||||
!checkStartWithHttp(slug) &&
|
||||
row.type.indexOf('Menu') < 0
|
||||
)
|
||||
}
|
||||
@@ -85,6 +85,6 @@ export function checkSlugHasMorThanTwoSlash(row) {
|
||||
return (
|
||||
(slug.match(/\//g) || []).length >= 2 &&
|
||||
row.type.indexOf('Menu') < 0 &&
|
||||
!checkContainHttp(slug)
|
||||
!checkStartWithHttp(slug)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user