Skip to content

Commit

Permalink
Supporting base url configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Gottfredsen committed Jan 2, 2025
1 parent f329dcb commit 4e3ecc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/lib/state/state-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ export class StateManager {
logger.debug("encode state");
const encoded = await lzEncode(JSON.stringify(state));
const header: FragmentHeader = "c";
window.history.replaceState(null, "", window.location.origin + window.location.search);
window.history.replaceState(
null,
"",
window.location.origin + import.meta.env.BASE_URL + window.location.search,
);
window.location.hash = header + encoded;
}

Expand All @@ -25,7 +29,7 @@ export class StateManager {
async load(): Promise<State> {
checkLegacyParams();
const fragment = StringUtils.trimPrefix(window.location.hash, "#");
const path = StringUtils.trimPrefix(window.location.pathname, "/");
const path = StringUtils.trimPrefix(window.location.pathname, import.meta.env.BASE_URL);
if (fragment === "" && path === "") {
return DEFUALT_STATE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utility/playground-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DIALECT_CONSTRUCTORS, QUERY_EDITOR_HEADER_DELIMITER } from "../constant

export class PlaygroundUtils {
static getEntrypointUrl() {
return window.origin + `/playground.js`;
return window.origin + import.meta.env.BASE_URL + `/playground.js`;
}

static makeQueryEditorHeader(dialect: string) {
Expand Down

0 comments on commit 4e3ecc3

Please sign in to comment.