This commit is contained in:
Adria Navarro 2023-12-14 10:31:04 +01:00
parent 251663f38c
commit a0dd71f990
1 changed files with 4 additions and 4 deletions

View File

@ -96,7 +96,7 @@ export async function getAppIdFromCtx(ctx: Ctx) {
} }
// look in the path // look in the path
const pathId = parseAppIdFromUrl(ctx.path) const pathId = parseAppIdFromUrlPath(ctx.path)
if (!appId && pathId) { if (!appId && pathId) {
appId = confirmAppId(pathId) appId = confirmAppId(pathId)
} }
@ -116,19 +116,19 @@ export async function getAppIdFromCtx(ctx: Ctx) {
// referer header is present from a builder redirect // referer header is present from a builder redirect
const referer = ctx.request.headers.referer const referer = ctx.request.headers.referer
if (!appId && referer?.includes(BUILDER_APP_PREFIX)) { if (!appId && referer?.includes(BUILDER_APP_PREFIX)) {
const refererId = parseAppIdFromUrl(ctx.request.headers.referer) const refererId = parseAppIdFromUrlPath(ctx.request.headers.referer)
appId = confirmAppId(refererId) appId = confirmAppId(refererId)
} }
return appId return appId
} }
function parseAppIdFromUrl(url?: string) { function parseAppIdFromUrlPath(url?: string) {
if (!url) { if (!url) {
return return
} }
return url return url
.split("?")[0] .split("?")[0] // Remove any possible query string
.split("/") .split("/")
.find(subPath => subPath.startsWith(APP_PREFIX)) .find(subPath => subPath.startsWith(APP_PREFIX))
} }