Compare commits
2 commits
d4a5ed29db
...
76aef3de74
Author | SHA1 | Date | |
---|---|---|---|
76aef3de74 | |||
dbdb2b70f1 |
3 changed files with 10 additions and 10 deletions
|
@ -15,11 +15,13 @@ export function removeTracking(url: string): string {
|
|||
parsed.searchParams.delete('si'); // source identifier
|
||||
} else if (['heise.de', 'www.heise.de'].includes(parsed.host)) {
|
||||
parsed.searchParams.delete('wt_mc');
|
||||
} else if (['derstandard.at', 'www.derstandard.at'].includes(parsed.host)) {
|
||||
parsed.searchParams.delete('ref');
|
||||
} else if (['tagesschau.de'].includes(parsed.host)) {
|
||||
parsed.searchParams.delete('at_medium');
|
||||
parsed.searchParams.delete('at_campaign');
|
||||
} else if (!isMobile && /\.m\.wikipedia\.org$/i.test(parsed.host)) {
|
||||
parsed.host = parsed.host.replace('.m.', '.');
|
||||
} else {
|
||||
parsed.searchParams.delete('ref');
|
||||
parsed.searchParams.delete('utm_source');
|
||||
parsed.searchParams.delete('utm_medium');
|
||||
parsed.searchParams.delete('utm_campaign');
|
||||
|
|
|
@ -27,7 +27,7 @@ export const api = ((endpoint: string, data: Record<string, any> = {}, token?: s
|
|||
const authorization = authorizationToken ? `Bearer ${authorizationToken}` : undefined;
|
||||
|
||||
const promise = new Promise<void>((resolve, reject) => {
|
||||
fetch(endpoint.indexOf('://') > -1 ? endpoint : `${apiUrl}/${endpoint}`, {
|
||||
fetch(`${apiUrl}/${endpoint}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
credentials: 'omit',
|
||||
|
@ -37,13 +37,12 @@ export const api = ((endpoint: string, data: Record<string, any> = {}, token?: s
|
|||
...(authorization ? { authorization } : {}),
|
||||
},
|
||||
}).then(async (res) => {
|
||||
const body = res.status === 204 ? null : await res.json();
|
||||
|
||||
if (res.status === 200) {
|
||||
resolve(body);
|
||||
resolve(await res.json());
|
||||
} else if (res.status === 204) {
|
||||
resolve();
|
||||
} else {
|
||||
const body = await res.json();
|
||||
reject(body.error);
|
||||
}
|
||||
}).catch(reject);
|
||||
|
@ -77,13 +76,12 @@ export const apiGet = ((endpoint: string, data: Record<string, any> = {}, token?
|
|||
...(authorization ? { authorization } : {}),
|
||||
},
|
||||
}).then(async (res) => {
|
||||
const body = res.status === 204 ? null : await res.json();
|
||||
|
||||
if (res.status === 200) {
|
||||
resolve(body);
|
||||
resolve(await res.json());
|
||||
} else if (res.status === 204) {
|
||||
resolve();
|
||||
} else {
|
||||
const body = await res.json();
|
||||
reject(body.error);
|
||||
}
|
||||
}).catch(reject);
|
||||
|
|
|
@ -23,7 +23,7 @@ export async function initializeSw() {
|
|||
function encode(buffer: ArrayBuffer | null) {
|
||||
return btoa(String.fromCharCode.apply(null, new Uint8Array(buffer)));
|
||||
}
|
||||
|
||||
|
||||
// Register
|
||||
api('sw/register', {
|
||||
endpoint: subscription.endpoint,
|
||||
|
|
Loading…
Add table
Reference in a new issue