Fix relative paths (#4594)
* 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
This commit is contained in:
@ -74,42 +74,6 @@ describe("util", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("resolveBase", () => {
|
||||
beforeEach(() => {
|
||||
const location: LocationLike = {
|
||||
pathname: "/healthz",
|
||||
origin: "http://localhost:8080",
|
||||
}
|
||||
|
||||
// Because resolveBase is not a pure function
|
||||
// and relies on the global location to be set
|
||||
// we set it before all the tests
|
||||
// and tell TS that our location should be looked at
|
||||
// as Location (even though it's missing some properties)
|
||||
global.location = location as Location
|
||||
})
|
||||
|
||||
it("should resolve a base", () => {
|
||||
expect(util.resolveBase("localhost:8080")).toBe("/localhost:8080")
|
||||
})
|
||||
|
||||
it("should resolve a base with a forward slash at the beginning", () => {
|
||||
expect(util.resolveBase("/localhost:8080")).toBe("/localhost:8080")
|
||||
})
|
||||
|
||||
it("should resolve a base with query params", () => {
|
||||
expect(util.resolveBase("localhost:8080?folder=hello-world")).toBe("/localhost:8080")
|
||||
})
|
||||
|
||||
it("should resolve a base with a path", () => {
|
||||
expect(util.resolveBase("localhost:8080/hello/world")).toBe("/localhost:8080/hello/world")
|
||||
})
|
||||
|
||||
it("should resolve a base to an empty string when not provided", () => {
|
||||
expect(util.resolveBase()).toBe("")
|
||||
})
|
||||
})
|
||||
|
||||
describe("arrayify", () => {
|
||||
it("should return value it's already an array", () => {
|
||||
expect(util.arrayify(["hello", "world"])).toStrictEqual(["hello", "world"])
|
||||
|
Reference in New Issue
Block a user