mirror of
https://github.com/langgenius/dify.git
synced 2026-11-13 14:51:39 +08:00
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>
15 lines
530 B
TypeScript
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
|
|
}
|
|
}
|