Skip to content

Commit 721755d

Browse files
javoskiyyx990803
authored andcommitted
small tweaks on resolvePath function (#1287)
1 parent 6f5ce40 commit 721755d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/util/path.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ export function resolvePath (
55
base: string,
66
append?: boolean
77
): string {
8-
if (relative.charAt(0) === '/') {
8+
const firstChar = relative.charAt(0)
9+
if (firstChar === '/') {
910
return relative
1011
}
1112

12-
if (relative.charAt(0) === '?' || relative.charAt(0) === '#') {
13+
if (firstChar === '?' || firstChar === '#') {
1314
return base + relative
1415
}
1516

@@ -26,11 +27,9 @@ export function resolvePath (
2627
const segments = relative.replace(/^\//, '').split('/')
2728
for (let i = 0; i < segments.length; i++) {
2829
const segment = segments[i]
29-
if (segment === '.') {
30-
continue
31-
} else if (segment === '..') {
30+
if (segment === '..') {
3231
stack.pop()
33-
} else {
32+
} else if (segment !== '.') {
3433
stack.push(segment)
3534
}
3635
}

0 commit comments

Comments
 (0)