修复外链编译打包问题

This commit is contained in:
tangly1024.com
2024-06-26 11:12:38 +08:00
parent 50d79ebe88
commit 8f0ae9267a
3 changed files with 30 additions and 25 deletions

View File

@@ -47,7 +47,12 @@ export const memorize = Component => {
return memo(MemoizedComponent)
}
// 转换外链
/**
* 诸如 article/https://test.com 等被错误拼接前缀的slug进行处理
* 转换为 https://test.com
* @param {*} str
* @returns
*/
export function sliceUrlFromHttp(str) {
// 检查字符串是否包含http
if (str?.includes('http:') || str?.includes('https:')) {
@@ -99,7 +104,7 @@ export function checkStartWithHttp(str) {
// 检查字符串是否包含http
if (str?.indexOf('http:') === 0 || str?.indexOf('https:') === 0) {
// 如果包含找到http的位置
return str?.indexOf('http') > -1
return true
} else {
// 不包含
return false