mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-06-22 06:03:49 +08:00
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:
@@ -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}`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user