-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #332 from edlerd/use-relative-ui-paths
fix: ui uses relative base paths.
- Loading branch information
Showing
15 changed files
with
533 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#! /usr/bin/env bash | ||
set -e | ||
|
||
echo "Listening on http://localhost:8411" | ||
echo "Listening on http://localhost:8411/ui/" | ||
|
||
haproxy -f haproxy.cfg -db |
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
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,33 @@ | ||
import { calculateBasePath } from "./basePaths"; | ||
|
||
describe("calculateBasePath", () => { | ||
it("resolves with ui path", () => { | ||
vi.stubGlobal("location", { pathname: "/ui/" }); | ||
const result = calculateBasePath(); | ||
expect(result).toBe("/ui/"); | ||
}); | ||
|
||
it("resolves with ui path and discards detail page location", () => { | ||
vi.stubGlobal("location", { pathname: "/ui/foo/bar" }); | ||
const result = calculateBasePath(); | ||
expect(result).toBe("/ui/"); | ||
}); | ||
|
||
it("resolves with prefixed ui path", () => { | ||
vi.stubGlobal("location", { pathname: "/prefix/ui/" }); | ||
const result = calculateBasePath(); | ||
expect(result).toBe("/prefix/ui/"); | ||
}); | ||
|
||
it("resolves with prefixed ui path on a detail page", () => { | ||
vi.stubGlobal("location", { pathname: "/prefix/ui/foo/bar/baz" }); | ||
const result = calculateBasePath(); | ||
expect(result).toBe("/prefix/ui/"); | ||
}); | ||
|
||
it("resolves with root path if /ui/ is not part of the pathname", () => { | ||
vi.stubGlobal("location", { pathname: "/foo/bar/baz" }); | ||
const result = calculateBasePath(); | ||
expect(result).toBe("/"); | ||
}); | ||
}); |
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,14 @@ | ||
type BasePath = `/${string}`; | ||
|
||
export const calculateBasePath = (): BasePath => { | ||
const path = window.location.pathname; | ||
// find first occurrence of /ui/ and return the string before it | ||
const basePath = path.match(/(.*\/ui\/)/); | ||
if (basePath) { | ||
return basePath[0] as BasePath; | ||
} | ||
return "/"; | ||
}; | ||
|
||
export const basePath: BasePath = calculateBasePath(); | ||
export const apiBasePath: BasePath = `${basePath}../api/v0/`; |
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.