-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tests for relativeRoot * Remove path.posix.join Since this is for file system paths it feels incorrect to use it on URL paths as they are different in many ways. * Rewrite cookie path logic Before we relied on the client to resolve the base given to it by the backend against the path. Instead have the client pass that information along so we can resolve it on the backend. This means the client has to do less work. * Do not remove out directory before watch This is re-used for incremental compilation. Also remove del since that was the only use (and we can use fs.rmdir in the future if we need something like this). * Remove unused function resolveBase
- Loading branch information
1 parent
9d9f3a4
commit 4b4ec37
Showing
14 changed files
with
91 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
import { Router } from "express" | ||
import { CookieKeys } from "../../common/http" | ||
import { getCookieDomain, redirect } from "../http" | ||
|
||
import { getCookieOptions, redirect } from "../http" | ||
import { sanitizeString } from "../util" | ||
|
||
export const router = Router() | ||
|
||
router.get<{}, undefined, undefined, { base?: string; to?: string }>("/", async (req, res) => { | ||
const path = sanitizeString(req.query.base) || "/" | ||
const to = sanitizeString(req.query.to) || "/" | ||
|
||
// Must use the *identical* properties used to set the cookie. | ||
res.clearCookie(CookieKeys.Session, { | ||
domain: getCookieDomain(req.headers.host || "", req.args["proxy-domain"]), | ||
path: decodeURIComponent(path), | ||
sameSite: "lax", | ||
}) | ||
res.clearCookie(CookieKeys.Session, getCookieOptions(req)) | ||
|
||
return redirect(req, res, to, { to: undefined, base: undefined }) | ||
const to = sanitizeString(req.query.to) || "/" | ||
return redirect(req, res, to, { to: undefined, base: undefined, href: undefined }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { relativeRoot } from "../../../src/node/http" | ||
|
||
describe("http", () => { | ||
it("should construct a relative path to the root", () => { | ||
expect(relativeRoot("/")).toStrictEqual(".") | ||
expect(relativeRoot("/foo")).toStrictEqual(".") | ||
expect(relativeRoot("/foo/")).toStrictEqual("./..") | ||
expect(relativeRoot("/foo/bar ")).toStrictEqual("./..") | ||
expect(relativeRoot("/foo/bar/")).toStrictEqual("./../..") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.