Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 215ddbb

Browse files
committedDec 8, 2021
Remove unused function resolveBase
1 parent 4d5d97f commit 215ddbb

File tree

2 files changed

+0
-51
lines changed

2 files changed

+0
-51
lines changed
 

‎src/common/util.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,6 @@ export const trimSlashes = (url: string): string => {
4141
return url.replace(/^\/+|\/+$/g, "")
4242
}
4343

44-
/**
45-
* Resolve a relative base against the window location. This is used for
46-
* anything that doesn't work with a relative path.
47-
*/
48-
export const resolveBase = (base?: string): string => {
49-
// After resolving the base will either start with / or be an empty string.
50-
if (!base || base.startsWith("/")) {
51-
return base ?? ""
52-
}
53-
const parts = location.pathname.split("/")
54-
parts[parts.length - 1] = base
55-
const url = new URL(location.origin + "/" + parts.join("/"))
56-
return normalize(url.pathname)
57-
}
58-
5944
/**
6045
* Wrap the value in an array if it's not already an array. If the value is
6146
* undefined return an empty array.

‎test/unit/common/util.test.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -74,42 +74,6 @@ describe("util", () => {
7474
})
7575
})
7676

77-
describe("resolveBase", () => {
78-
beforeEach(() => {
79-
const location: LocationLike = {
80-
pathname: "/healthz",
81-
origin: "http://localhost:8080",
82-
}
83-
84-
// Because resolveBase is not a pure function
85-
// and relies on the global location to be set
86-
// we set it before all the tests
87-
// and tell TS that our location should be looked at
88-
// as Location (even though it's missing some properties)
89-
global.location = location as Location
90-
})
91-
92-
it("should resolve a base", () => {
93-
expect(util.resolveBase("localhost:8080")).toBe("/localhost:8080")
94-
})
95-
96-
it("should resolve a base with a forward slash at the beginning", () => {
97-
expect(util.resolveBase("/localhost:8080")).toBe("/localhost:8080")
98-
})
99-
100-
it("should resolve a base with query params", () => {
101-
expect(util.resolveBase("localhost:8080?folder=hello-world")).toBe("/localhost:8080")
102-
})
103-
104-
it("should resolve a base with a path", () => {
105-
expect(util.resolveBase("localhost:8080/hello/world")).toBe("/localhost:8080/hello/world")
106-
})
107-
108-
it("should resolve a base to an empty string when not provided", () => {
109-
expect(util.resolveBase()).toBe("")
110-
})
111-
})
112-
11377
describe("arrayify", () => {
11478
it("should return value it's already an array", () => {
11579
expect(util.arrayify(["hello", "world"])).toStrictEqual(["hello", "world"])

0 commit comments

Comments
 (0)
Please sign in to comment.