Skip to content

Commit

Permalink
fixed PATH_INFO problem
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Butcher <matt.butcher@microsoft.com>
  • Loading branch information
technosophos committed Aug 22, 2021
1 parent 3c542f4 commit 18b85da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# These are for both `run` (implicit) and `test` (explicit)
PATH_INFO ?= /static/fileserver.gr
PATH_INFO ?= /fileserver.gr
X_MATCHED_ROUTE ?= /static/...
BINDLE_SERVER_URL ?= http://localhost:8080/v1

Expand Down
13 changes: 7 additions & 6 deletions fileserver.gr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import String from "string"
import Mediatype from "./lib/mediatype"
import Stringutil from "./lib/stringutil"

let serve = (path) => {
let serve = (abs_path) => {
// Trim the leading /
let path = String.slice(1, String.length(abs_path), abs_path)
File.fdWrite(File.stderr, "Fileserver: Loading file ")
File.fdWrite(File.stderr, path)
File.fdWrite(File.stderr, "\n")
Expand Down Expand Up @@ -45,14 +47,13 @@ let serve = (path) => {
}

let guestpath = (env) => {

// Backward compat for an older version of Wagi that had PATH_INFO wrong.
// X_RELATIVE_PATH was removed before Wagi 0.4
match (Map.get("X_RELATIVE_PATH", env)) {
Some(p) => p,
None => {
// Backwards compat until Wagi 0.1.0 is released
let req = Option.unwrap(Map.get("PATH_INFO", env))
let matched = Option.unwrap(Map.get("X_MATCHED_ROUTE", env))
let base = Stringutil.beforeLast("/...", matched)
String.slice(String.length(base) + 1, String.length(req), req)
Option.unwrap(Map.get("PATH_INFO", env))
}
}

Expand Down

0 comments on commit 18b85da

Please sign in to comment.