diff --git a/ts/lib/generated/post.ts b/ts/lib/generated/post.ts index d3f44cd09..be9e962be 100644 --- a/ts/lib/generated/post.ts +++ b/ts/lib/generated/post.ts @@ -1,13 +1,16 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +import { isWindows } from "@tslib/platform"; + export interface PostProtoOptions { /** True by default. Shows a dialog with the error message, then rethrows. */ alertOnError?: boolean; + // whether to use the "anki:" custom protocol or not customProtocol?: boolean; } -const CUSTOM_PROTOCOL_URI = (navigator.platform.indexOf("Win") == -1) ? "anki://localhost" : "http://anki.localhost"; +const CUSTOM_PROTOCOL_URI = isWindows() ? "http://anki.localhost" : "anki://localhost" ; export async function postProto( method: string, diff --git a/ts/lib/tslib/platform.ts b/ts/lib/tslib/platform.ts index d055bcb53..d9727c3a2 100644 --- a/ts/lib/tslib/platform.ts +++ b/ts/lib/tslib/platform.ts @@ -10,6 +10,11 @@ export function isApplePlatform(): boolean { ); } +export function isWindows(): boolean { + const platform = window.navigator["platform" + ""]; + return platform.startsWith("Win"); +} + export function isDesktop(): boolean { return !(/iphone|ipad|ipod|android/i.test(window.navigator.userAgent)); }