Skip to content

Commit

Permalink
perf: 优化getPath,获取hash path时,去掉search部分
Browse files Browse the repository at this point in the history
  • Loading branch information
Chryseis committed Dec 15, 2021
1 parent 9479bb3 commit ac95256
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/web-performance/src/utils/getPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const getPath = (location: Location, isHash: boolean) => {
} else {
const index = location.href.indexOf('#')
if (index < 0) return ''
return location.href.slice(index + 1)
const hash = location.href.slice(index + 1)
const searchIndex = hash.indexOf('?')
if (searchIndex < 0) return hash
return hash.slice(0, searchIndex)
}
}

Expand Down

0 comments on commit ac95256

Please sign in to comment.