diff --git a/vue/src/util/path.ts b/vue/src/util/path.ts index 78a7615..c5abe58 100644 --- a/vue/src/util/path.ts +++ b/vue/src/util/path.ts @@ -28,10 +28,9 @@ export function normalize (path: string): string { // 重新组合路径 const result = newParts.join('/') - // 如果原始路径以斜杠结尾,则结果也以斜杠结尾 - const endsWithSlash = path.endsWith('/') - if (endsWithSlash && !result.endsWith('/')) { - return result + '/' + const startWithSlash = path.startsWith('/') + if (startWithSlash) { + return '/' + result } else { return result } @@ -46,7 +45,6 @@ export function join (...paths: string[]): string { // 规范化路径 result = normalize(result) - // 如果原始路径以斜杠结尾,则结果也以斜杠结尾 const endsWithSlash = paths[paths.length - 1].endsWith('/') if (endsWithSlash && !result.endsWith('/')) { @@ -71,4 +69,4 @@ export const splitPath = (path: string) => { frags[0] = frags[0] + '/'// 分割完是c: -> c:/ } return frags -} \ No newline at end of file +}