-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const paramNames = { | ||
pipingServerUrl: "server", | ||
pipingServerHeaders: "headers", | ||
csPath: "cs_path", | ||
scPath: "sc_path", | ||
autoConnect: "auto_connect", | ||
}; | ||
|
||
export const fragmentParams = { | ||
pipingServerUrl(): string | undefined { | ||
return parseFragmentParams().get(paramNames.pipingServerUrl) ?? undefined; | ||
}, | ||
pipingServerHeaders(): Array<[string, string]> | undefined { | ||
const headersString = parseFragmentParams().get(paramNames.pipingServerHeaders); | ||
if (headersString === null) { | ||
return undefined; | ||
} | ||
let decoded: [string, string][]; | ||
try { | ||
decoded = JSON.parse(decodeURIComponent(headersString)); | ||
} catch { | ||
return undefined; | ||
} | ||
return decoded; | ||
}, | ||
csPath(): string | undefined { | ||
return parseFragmentParams().get(paramNames.csPath) ?? undefined; | ||
}, | ||
scPath(): string | undefined { | ||
return parseFragmentParams().get(paramNames.scPath) ?? undefined; | ||
}, | ||
autoConnect(): boolean | undefined { | ||
const str = parseFragmentParams().get(paramNames.autoConnect); | ||
return str !== null && ["", "1", "true"].includes(str); | ||
} | ||
}; | ||
|
||
function parseFragmentParams(): URLSearchParams { | ||
const url = new URL(`a://a${location.hash.substring(1)}`); | ||
return url.searchParams; | ||
} |
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
0e9e620
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://piping-adb.nwtgck.org as production
🚀 Deployed on https://649c12a6cebf9e0a3f64f5ae--piping-adb.netlify.app