cmc-web/packages/common/components/utils/resolvePath.js

14 lines
325 B
JavaScript
Raw Normal View History

2024-08-20 12:11:31 +00:00
/**
* Created by HaijunZhang on 2018/12/10.
*/
2024-08-21 01:17:14 +00:00
import path from 'path'
export function isExternalLink(path) {
return /^(http:|https:|mailto:|tel:)\/\//.test(path)
2024-08-20 12:11:31 +00:00
}
2024-08-21 01:17:14 +00:00
export function resolvePath(basePath, routePath) {
2024-08-20 12:11:31 +00:00
if (isExternalLink(routePath)) {
2024-08-21 01:17:14 +00:00
return routePath
2024-08-20 12:11:31 +00:00
}
2024-08-21 01:17:14 +00:00
return path.resolve(basePath, routePath)
2024-08-20 12:11:31 +00:00
}