usePullRequestParam: Provisioned dashboard preview banner, decode pull request url before sanitize (#114516)

usePullRequestParam: decode url before sanitize
This commit is contained in:
Yunwen Zheng
2025-11-27 08:03:36 +02:00
committed by GitHub
parent 84a07be6e4
commit cb05a4ae1b
2 changed files with 12 additions and 7 deletions
@@ -107,9 +107,14 @@ export function PreviewBannerViewPR({ prParam, isNewPr, behindBranch, repoUrl, b
{/* when repo type is not local, we show branch information */}
{showBranchInfo(repoType, branchInfo) && (
<Box marginTop={1}>
<Trans i18nKey="provisioned-resource-preview-banner.preview-banner.branch-text">branch: </Trans>
<TextLink href={getBranchUrl(repoBaseUrl!, targetBranch!, repoType)}>{targetBranch}</TextLink> {'\u2192'}{' '}
<TextLink href={getBranchUrl(repoBaseUrl!, configuredBranch!, repoType)}>{configuredBranch}</TextLink>
<Trans i18nKey="provisioned-resource-preview-banner.preview-banner.branch-text">branch:</Trans>{' '}
<TextLink href={getBranchUrl(repoBaseUrl!, targetBranch!, repoType)} external>
{targetBranch}
</TextLink>{' '}
{'\u2192'}{' '}
<TextLink href={getBranchUrl(repoBaseUrl!, configuredBranch!, repoType)} external>
{configuredBranch}
</TextLink>
</Box>
)}
</Alert>
@@ -9,9 +9,9 @@ export const usePullRequestParam = () => {
const repoType = params.get('repo_type');
return {
prURL: prParam ? textUtil.sanitizeUrl(prParam) : undefined,
newPrURL: newPrParam ? textUtil.sanitizeUrl(newPrParam) : undefined,
repoURL: repoUrl ? textUtil.sanitizeUrl(repoUrl) : undefined,
repoType: repoType ? textUtil.sanitizeUrl(repoType) : undefined,
prURL: prParam ? textUtil.sanitizeUrl(decodeURIComponent(prParam)) : undefined,
newPrURL: newPrParam ? textUtil.sanitizeUrl(decodeURIComponent(newPrParam)) : undefined,
repoURL: repoUrl ? textUtil.sanitizeUrl(decodeURIComponent(repoUrl)) : undefined,
repoType: repoType ? textUtil.sanitizeUrl(decodeURIComponent(repoType)) : undefined,
};
};