We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4218169 commit 908476cCopy full SHA for 908476c
1 file changed
src/frontend/src/lib/functions/urls.ts
@@ -2,6 +2,14 @@ export function resolve_partial_path(path: string) {
2
return new URL(path, window.location.href).pathname;
3
}
4
5
-export function strip_trailing_slash(url: string) {
6
- return url.replace(/\/$/, '');
+export function strip_trailing_slash(input: string) {
+ if (!input || input === '/') return input;
7
+
8
+ // Split off query string and hash
9
+ const [path, query = ''] = input.split('?');
10
+ const [cleanPath, hash = ''] = path.split('#');
11
12
+ const normalizedPath = cleanPath.replace(/\/+$/, '');
13
14
+ return normalizedPath + (query ? '?' + query : '') + (hash ? '#' + hash : '');
15
0 commit comments