fix: Invalid URL at deeplink handler at startup

fixes #613
This commit is contained in:
lin onetwo 2025-02-12 00:36:32 +08:00
parent f1ac503a96
commit 105b87f981

View file

@ -18,6 +18,7 @@ export class DeepLinkService implements IDeepLinkService {
*/
private readonly deepLinkHandler: (requestUrl: string) => Promise<void> = async (requestUrl) => {
logger.info(`Receiving deep link`, { requestUrl, function: 'deepLinkHandler' });
try {
// hostname is workspace id or name
const { hostname, hash, pathname } = new URL(requestUrl);
let workspace = await this.workspaceService.get(hostname);
@ -42,6 +43,9 @@ export class DeepLinkService implements IDeepLinkService {
tiddlerName = decodeURIComponent(tiddlerName);
logger.info(`Open deep link`, { workspaceId: workspace.id, tiddlerName, function: 'deepLinkHandler' });
await this.workspaceService.openWorkspaceTiddler(workspace, tiddlerName);
} catch (error) {
logger.error(`Invalid URL`, { requestUrl, error, function: 'deepLinkHandler' });
}
};
public initializeDeepLink(protocol: string) {