Skip to content

Commit 5536f81

Browse files
author
Andrea Bonomi
committed
make prepareHref more robust
1 parent 4a54916 commit 5536f81

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

airflow_code_editor/static/airflow_code_editor.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commons.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export function basename(path) {
4848

4949
export function prepareHref(path) {
5050
// Return the full path of the URL
51-
return document.location.pathname + path;
51+
let pathname = document.location.pathname;
52+
pathname = pathname.endsWith('/') ? pathname.slice(0, -1) : pathname;
53+
path = path.startsWith('/') ? path.slice(1) : path;
54+
return pathname + '/' + path;
5255
}
5356

5457
export function splitPath(path) {

0 commit comments

Comments
 (0)