Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit c27fec8

Browse files
authored
Merge pull request #5 from technosophos/feat/use-x-relative-path
Use X_RELATIVE_PATH when available
2 parents 9a5640a + 5ea9186 commit c27fec8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

fileserver.gr

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,17 @@ let serve = (path) => {
4545
}
4646

4747
let guestpath = (env) => {
48-
let req = Option.unwrap(Map.get("PATH_INFO", env))
49-
let matched = Option.unwrap(Map.get("X_MATCHED_ROUTE", env))
50-
let base = Stringutil.beforeLast("/...", matched)
51-
String.slice(String.length(base) + 1, String.length(req), req)
48+
match (Map.get("X_RELATIVE_PATH", env)) {
49+
Some(p) => p,
50+
None => {
51+
// Backwards compat until Wagi 0.1.0 is released
52+
let req = Option.unwrap(Map.get("PATH_INFO", env))
53+
let matched = Option.unwrap(Map.get("X_MATCHED_ROUTE", env))
54+
let base = Stringutil.beforeLast("/...", matched)
55+
String.slice(String.length(base) + 1, String.length(req), req)
56+
}
57+
}
58+
5259
}
5360

5461
let notFound = () => {

0 commit comments

Comments
 (0)