forked from tsai/budibase
8 changed files with 28 additions and 20 deletions
@ -1,4 +1,15 @@ |
|||||
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