Improve routing
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
export interface Application {
|
||||
readonly comment?: string
|
||||
readonly directory?: string
|
||||
readonly embedPath?: string
|
||||
readonly exec?: string
|
||||
readonly icon?: string
|
||||
readonly loaded?: boolean
|
||||
|
@ -1,6 +1,9 @@
|
||||
import { logger } from "@coder/logger"
|
||||
import { Application } from "../common/api"
|
||||
|
||||
export interface Options {
|
||||
app?: Application
|
||||
authed?: boolean
|
||||
logLevel?: number
|
||||
}
|
||||
|
||||
@ -27,6 +30,9 @@ export const generateUuid = (length = 24): string => {
|
||||
* Get options embedded in the HTML from the server.
|
||||
*/
|
||||
export const getOptions = <T extends Options>(): T => {
|
||||
if (typeof document === "undefined") {
|
||||
return {} as T
|
||||
}
|
||||
const el = document.getElementById("coder-options")
|
||||
try {
|
||||
if (!el) {
|
||||
@ -46,3 +52,10 @@ export const getOptions = <T extends Options>(): T => {
|
||||
return {} as T
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove extra slashes in a URL.
|
||||
*/
|
||||
export const normalize = (url: string, keepTrailing = false): string => {
|
||||
return url.replace(/\/\/+/g, "/").replace(/\/+$/, keepTrailing ? "/" : "")
|
||||
}
|
||||
|
Reference in New Issue
Block a user