From e8e71838b34be3bcbb63a944ec12ce1f6e14e07e Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Thu, 29 Nov 2018 01:45:19 +0100 Subject: [PATCH] fix(angular): accept other url schemas --- angular/src/directives/navigation/href-delegate.ts | 4 +++- core/src/utils/theme.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/angular/src/directives/navigation/href-delegate.ts b/angular/src/directives/navigation/href-delegate.ts index 272c1e61dd..a614d915f0 100644 --- a/angular/src/directives/navigation/href-delegate.ts +++ b/angular/src/directives/navigation/href-delegate.ts @@ -32,9 +32,11 @@ export class HrefDelegate { this.navCtrl.setDirection(this.routerDirection); } - if (!this.routerLink && this.router && url != null && url[0] !== '#' && url.indexOf('://') === -1) { + if (!this.routerLink && this.router && url != null && url[0] !== '#' && !SCHEME.test(url)) { ev.preventDefault(); this.router.navigateByUrl(url); } } } + +const SCHEME = /^[a-z][a-z0-9+\-.]*:/; diff --git a/core/src/utils/theme.ts b/core/src/utils/theme.ts index 7b20e78507..1a2b10ceb8 100644 --- a/core/src/utils/theme.ts +++ b/core/src/utils/theme.ts @@ -38,8 +38,10 @@ export function getClassMap(classes: string | string[] | undefined): CssClassMap return map; } +const SCHEME = /^[a-z][a-z0-9+\-.]*:/; + export async function openURL(win: Window, url: string | undefined | null, ev: Event | undefined | null, direction: RouterDirection): Promise { - if (url != null && url[0] !== '#' && url.indexOf('://') === -1) { + if (url != null && url[0] !== '#' && !SCHEME.test(url)) { const router = win.document.querySelector('ion-router'); if (router) { if (ev != null) {