feat(deeplink): add support for apt:// protocol conversion to spk://search

Add handling for apt://pkgname format links by converting them to
spk://search/pkgname protocol, allowing spark-store to process
apt package links seamlessly

refs #IJTPFP
This commit is contained in:
gitee-bot
2026-06-10 11:36:31 +00:00
parent 8e8617218a
commit e39525901e
+17 -1
View File
@@ -45,7 +45,7 @@ class ListenersMap {
} }
} }
const protocols = ["spk"]; const protocols = ["spk", "apt"];
const listeners = new ListenersMap(); const listeners = new ListenersMap();
export const deepLink = { export const deepLink = {
@@ -81,6 +81,22 @@ export function handleCommandLine(commandLine: string[]) {
try { try {
const url = new URL(target); const url = new URL(target);
// Handle apt:// protocol: convert to spk://search/pkgname
if (url.protocol === "apt:") {
// Format: apt://pkgname
const pkgname = url.hostname || url.pathname.split("/").filter(Boolean)[0];
if (pkgname) {
const query: Query = { pkgname };
logger.info(`Deep link: apt protocol converted to search: ${pkgname}`);
listeners.emit("search", query);
} else {
logger.warn(
`Deep link: invalid apt format, expected //pkgname, got ${target}`,
);
}
return;
}
const action = url.hostname; // 'search' const action = url.hostname; // 'search'
logger.info(`Deep link: action found: ${action}`); logger.info(`Deep link: action found: ${action}`);