Fix AllowedHost to store parsed host instead of raw input
Store `parsed.host` from the WHATWG URL parser instead of the raw lowercased input string. This ensures the stored allowlist entries match what `normalizeRequestHost` produces at request time: - Trailing slashes are stripped (e.g. "app.example/" → "app.example") - Default HTTP ports are stripped (e.g. "app.example:80" → "app.example") Both normalizations already happen in `normalizeRequestHost` via `new URL(...).host`, so applying the same transform at storage time keeps the two sides consistent. Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 parent
11091bf337
commit
ec7629b2b1
1 file changed
+7
-1
@@ -74,7 +74,13 @@ const AllowedHost = Schema.Trim.pipe(
|
||||
{ identifier: "AllowedHost" },
|
||||
),
|
||||
),
|
||||
Schema.decodeTo(Schema.String, SchemaTransformation.toLowerCase()),
|
||||
Schema.decodeTo(
|
||||
Schema.String,
|
||||
SchemaTransformation.transform({
|
||||
decode: (input) => new URL(`http://${input}`).host,
|
||||
encode: (input) => input,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const AllowedHostsCsv = Schema.String.pipe(
|
||||
|
||||
Reference in new issue
Block a user