forked from tsai/budibase
committed by
GitHub
8 changed files with 30 additions and 20 deletions
@ -1,4 +1,17 @@ |
|||||
export const getAppIdFromPath = () => { |
const COOKIE_SEPARATOR = ";" |
||||
|
const APP_PREFIX = "app_" |
||||
|
const KEY_VALUE_SPLIT = "=" |
||||
|
|
||||
|
export const getAppId = allCookies => { |
||||
|
const cookie = allCookies |
||||
|
.split(COOKIE_SEPARATOR) |
||||
|
.find(cookie => cookie.trim().startsWith("budibase:currentapp")) |
||||
let appId = location.pathname.split("/")[1] |
let appId = location.pathname.split("/")[1] |
||||
return appId && appId.startsWith("app_") ? appId : undefined |
appId = appId && appId.startsWith(APP_PREFIX) ? appId : undefined |
||||
|
if (!appId && cookie && cookie.split(KEY_VALUE_SPLIT).length === 2) { |
||||
|
appId = cookie.split("=")[1] |
||||
|
} |
||||
|
return appId |
||||
} |
} |
||||
|
|
||||
|
export const getAppIdFromPath = getAppId |
||||
|
|||||
Loading…
Reference in new issue