Skip to content

Commit

Permalink
fix(custom-schema): fix typo and better handling
Browse files Browse the repository at this point in the history
  • Loading branch information
4o3F committed Feb 29, 2024
1 parent 980e0e7 commit 1483758
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions backend/tauri/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<dict>
<key>CFBundleURLName</key>
<!-- Obviously needs to be replaced with your app's bundle identifier -->
<string>moe.elaina.clash.nyanpasu</string>
<string>Clash Nyanpasu</string>
<key>CFBundleURLSchemes</key>
<array>
<string>test-url</string>
<string>clash-nyanpasu</string>
</array>
</dict>
</array>
Expand Down
14 changes: 9 additions & 5 deletions src/pages/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ export default function Layout() {
});

listen("scheme-request-received", (req) => {
console.log("Received event");
let url: string = req.payload as string;
// remove first 5 letter of url
url = url.slice("clash-nyanpasu://".length);
navigate("/profile", { state: { scheme: url } });
const message: string = req.payload as string;
const url = new URL(message);
switch (url.pathname) {
case "//subscribe-remote-profile":
case "//subscribe-remote-profile/":
navigate("/profile", {
state: { scheme: url.searchParams.get("url") },
});
}
});

setTimeout(() => {
Expand Down

0 comments on commit 1483758

Please sign in to comment.