Skip to content

Commit 0191ed4

Browse files
MathiasVDACopilot
andauthored
Update packages/yasqe/src/sparql.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 88ca0bb commit 0191ed4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/yasqe/src/sparql.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,13 @@ function normalizeUrl(url: string): string {
372372
fullUrl += url;
373373
} else {
374374
// Relative path
375-
fullUrl += window.location.pathname + url;
375+
let basePath = window.location.pathname;
376+
// If pathname does not end with "/", treat it as a file and use its directory
377+
if (!basePath.endsWith("/")) {
378+
const lastSlashIndex = basePath.lastIndexOf("/");
379+
basePath = lastSlashIndex >= 0 ? basePath.substring(0, lastSlashIndex + 1) : "/";
380+
}
381+
fullUrl += basePath + url;
376382
}
377383
return fullUrl;
378384
}

0 commit comments

Comments
 (0)