Skip to content

Commit

Permalink
fix: don't use String.prototype.replaceAll
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Mar 1, 2024
1 parent 9d2d96c commit 9984ea5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/utils/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ export const encodePath = (path: string, all?: boolean) => {
return path
.split("/")
.map((p) =>
// ["#", "?", "%"].some((c) => p.includes(c)) ? encodeURIComponent(p) : p
all
? encodeURIComponent(p)
: p
.replaceAll("%", "%25")
.replaceAll("?", "%3F")
.replaceAll("#", "%23")
.replaceAll(" ", "%20"),
.replace(/%/g, "%25")
.replace(/\?/g, "%3F")
.replace(/#/g, "%23")
.replace(/ /g, "%20"),
)
.join("/")
}
Expand Down

0 comments on commit 9984ea5

Please sign in to comment.