From af7aca93ad844a95abc048fbbbdcb589517e2cd1 Mon Sep 17 00:00:00 2001 From: Ruben Romero Montes Date: Wed, 9 Jul 2025 12:09:12 +0200 Subject: [PATCH] fix: decode version and support debian package urls Signed-off-by: Ruben Romero Montes --- ui/src/utils/utils.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ui/src/utils/utils.ts b/ui/src/utils/utils.ts index 43582906..7dec42da 100644 --- a/ui/src/utils/utils.ts +++ b/ui/src/utils/utils.ts @@ -12,6 +12,9 @@ const NPM_URL = 'https://www.npmjs.com/package/' const PYPI_TYPE = 'pypi'; const PYPI_URL = 'https://pypi.org/project/'; +const DEBIAN_TYPE = 'deb'; +const DEBIAN_URL = 'https://sources.debian.org/patches/'; + const ISSUE_PLACEHOLDER = '__ISSUE_ID__'; const PURL_PKG_PREFIX = 'pkg:'; @@ -56,8 +59,9 @@ const extractName = (pkgUrl: PackageURL): string => { export const extractDependencyName = (name: string, showVersion: boolean) => { const pkgUrl = PackageURL.fromString(name); let result = extractName(pkgUrl); + const decodedVersion = pkgUrl.version ? decodeURIComponent(pkgUrl.version) : ''; if(showVersion) { - return result + `@${pkgUrl.version}`; + return result + `@${decodedVersion}`; } return result; }; @@ -98,13 +102,15 @@ export const extractDependencyUrl = (name: string) => { return `${PYPI_URL}${pkgUrl.namespace}/${pkgUrl.name}/${pkgUrl.version}` } return `${PYPI_URL}${pkgUrl.name}/${pkgUrl.version}` + case DEBIAN_TYPE: + return `${DEBIAN_URL}${pkgUrl.name}/${pkgUrl.version}` default: return pkgUrl.toString(); } }; export const extractDependencyVersion = (name: string): string => { const version = PackageURL.fromString(name).version; - return version ? version : ''; + return version ? decodeURIComponent(version) : ''; }; export const issueLink = (provider: string, issueId: string, appData: AppData) => {