From a9c56c7154fedb23c4490f6e33be60b79a53090a Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 25 May 2021 10:18:46 +1000 Subject: [PATCH] fix(#328) - use `Referer` instead of `Referrer` header Fixes #328 --- README.md | 10 +++++----- docs/FAQ.md | 2 +- response.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 98e6b525..d2d35aa0 100644 --- a/README.md +++ b/README.md @@ -418,11 +418,11 @@ And a method: A method to simplify redirecting the response to another URL. It will set the `Location` header to the supplied `url` and the status to `302 Found` (unless the status is already a `3XX` status). The use of symbol `REDIRECT_BACK` as - the `url` indicates that the `Referrer` header in the request should be used - as the direction, with the `alt` being the alternative location if the - `Referrer` is not set. If neither the `alt` nor the `Referrer` are set, the - redirect will occur to `/`. A basic HTML (if the requestor supports it) or a - text body will be set explaining they are being redirected. + the `url` indicates that the `Referer` header in the request should be used as + the direction, with the `alt` being the alternative location if the `Referer` + is not set. If neither the `alt` nor the `Referer` are set, the redirect will + occur to `/`. A basic HTML (if the requestor supports it) or a text body will + be set explaining they are being redirected. ### Automatic response body handling diff --git a/docs/FAQ.md b/docs/FAQ.md index a9fd4731..1b2c9682 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -76,7 +76,7 @@ await app.listen({ port: 8000 }); ``` The symbol `REDIRECT_BACK` can be used to redirect the requestor back to the to -the referrer (if the request's `Referrer` header has been set), and the second +the referrer (if the request's `Referer` header has been set), and the second argument can be used to provide a "backup" if there is no referrer. For example: ```ts diff --git a/response.ts b/response.ts index f173515e..0015a743 100644 --- a/response.ts +++ b/response.ts @@ -292,7 +292,7 @@ export class Response { alt: string | URL = "/", ): void { if (url === REDIRECT_BACK) { - url = this.#request.headers.get("Referrer") ?? String(alt); + url = this.#request.headers.get("Referer") ?? String(alt); } else if (typeof url === "object") { url = String(url); }