Skip to content

Commit

Permalink
fix(#328) - use Referer instead of Referrer header
Browse files Browse the repository at this point in the history
Fixes #328
  • Loading branch information
kitsonk committed May 25, 2021
1 parent 51c02fc commit a9c56c7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit a9c56c7

Please sign in to comment.