Files
8cbb6c0130 feat: HITL IM integration (#44864)
Co-authored-by: zxhlyh <jasonapring2015@outlook.com>
Co-authored-by: JzoNg <jzongcode@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-10-30 02:43:31 +00:00

15 lines
530 B
TypeScript

export const resolveConsoleHumanInputFormURL = (backstageURL: string, basePath = ''): string => {
try {
const url = new URL(backstageURL, 'http://localhost')
if (url.protocol !== 'http:' && url.protocol !== 'https:') return backstageURL
const match = url.pathname.match(/(?:^|\/)form\/([^/]+)\/?$/)
if (!match?.[1]) return backstageURL
const token = encodeURIComponent(decodeURIComponent(match[1]))
return `${basePath.replace(/\/$/, '')}/human-input/${token}`
} catch {
return backstageURL
}
}