Skip to content

Commit cde1507

Browse files
committed
fix trailing slash after anchor
1 parent 9c15c05 commit cde1507

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/common/Util.res

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module String = {
2626
let leadingSlash = str => str->String.startsWith("/") ? str : "/" ++ str
2727

2828
let trailingSlash = str => str->String.endsWith("/") ? str : str ++ "/"
29+
30+
let removeTrailingSlash = str->String.replaceRegExp(/\/$/, "")
2931
}
3032

3133
module Url = {
@@ -68,7 +70,7 @@ module Url = {
6870
let splitUrl = str->Stdlib.String.split("#")
6971

7072
`${splitUrl[0]->Option.getOr("")}/${splitUrl[1]
71-
->Option.map(anchor => "#" ++ anchor)
73+
->Option.map(anchor => "#" ++ anchor->String.removeTrailingSlash)
7274
->Option.getOr("")}`
7375
}
7476
}

0 commit comments

Comments
 (0)