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

Commit 18b85da

Browse files
committed
fixed PATH_INFO problem
Signed-off-by: Matt Butcher <[email protected]>
1 parent 3c542f4 commit 18b85da

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# These are for both `run` (implicit) and `test` (explicit)
2-
PATH_INFO ?= /static/fileserver.gr
2+
PATH_INFO ?= /fileserver.gr
33
X_MATCHED_ROUTE ?= /static/...
44
BINDLE_SERVER_URL ?= http://localhost:8080/v1
55

fileserver.gr

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import String from "string"
88
import Mediatype from "./lib/mediatype"
99
import Stringutil from "./lib/stringutil"
1010

11-
let serve = (path) => {
11+
let serve = (abs_path) => {
12+
// Trim the leading /
13+
let path = String.slice(1, String.length(abs_path), abs_path)
1214
File.fdWrite(File.stderr, "Fileserver: Loading file ")
1315
File.fdWrite(File.stderr, path)
1416
File.fdWrite(File.stderr, "\n")
@@ -45,14 +47,13 @@ let serve = (path) => {
4547
}
4648

4749
let guestpath = (env) => {
50+
51+
// Backward compat for an older version of Wagi that had PATH_INFO wrong.
52+
// X_RELATIVE_PATH was removed before Wagi 0.4
4853
match (Map.get("X_RELATIVE_PATH", env)) {
4954
Some(p) => p,
5055
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+
Option.unwrap(Map.get("PATH_INFO", env))
5657
}
5758
}
5859

0 commit comments

Comments
 (0)