Added URL support

This commit is contained in:
WardPearce
2024-10-09 08:47:06 +13:00
parent 88adf0578f
commit af592a63fb
2 changed files with 46 additions and 8 deletions
@@ -25,6 +25,30 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="materialious-auth" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="youtube.com"
android:pathPrefix="/watch" />
<data
android:scheme="https"
android:host="www.youtube.com"
android:pathPrefix="/watch" />
<data
android:scheme="https"
android:host="m.youtube.com"
android:pathPrefix="/watch" />
<data
android:scheme="https"
android:host="youtu.be"
android:pathPrefix="/watch" />
</intent-filter>
</activity>
<provider
+22 -8
View File
@@ -86,15 +86,29 @@
// Auth response handling for Mobile
App.addListener('appUrlOpen', (data) => {
const authUrl = new URL(data.url);
const username = authUrl.searchParams.get('username');
const token = authUrl.searchParams.get('token');
const url = new URL(data.url);
if (username && token) {
authStore.set({
username: username,
token: token
});
if (data.url.includes('youtu')) {
let videoId = url.searchParams.get('v');
if (!videoId) {
videoId = url.pathname.split('/')[1];
}
if (!videoId) {
return;
}
goto(`/watch/${videoId}`);
} else {
const username = url.searchParams.get('username');
const token = url.searchParams.get('token');
if (username && token) {
authStore.set({
username: username,
token: token
});
}
}
});