Merge pull request #2219 from dpalou/MOBILE-3213

Mobile 3213
main
Juan Leyva 2019-12-18 12:44:36 +01:00 committed by GitHub
commit ee648ee09e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 8 deletions

View File

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { Platform } from 'ionic-angular'; import { Platform } from 'ionic-angular';
import { Geolocation, GeolocationOptions } from '@ionic-native/geolocation'; import { Geolocation, GeolocationOptions } from '@ionic-native/geolocation';
import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component';
@ -30,8 +31,11 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
north: number; north: number;
east: number; east: number;
constructor(protected fb: FormBuilder, private platform: Platform, private geolocation: Geolocation, constructor(protected fb: FormBuilder,
private domUtils: CoreDomUtilsProvider) { protected platform: Platform,
protected geolocation: Geolocation,
protected domUtils: CoreDomUtilsProvider,
protected sanitizer: DomSanitizer) {
super(fb); super(fb);
} }
@ -58,16 +62,19 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
* @param east Degrees East. * @param east Degrees East.
* @return Link to maps depending on platform. * @return Link to maps depending on platform.
*/ */
getLatLongLink(north: number, east: number): string { getLatLongLink(north: number, east: number): SafeUrl {
if (north !== null || east !== null) { if (north !== null || east !== null) {
const northFixed = north ? north.toFixed(4) : '0.0000', const northFixed = north ? north.toFixed(4) : '0.0000';
eastFixed = east ? east.toFixed(4) : '0.0000'; const eastFixed = east ? east.toFixed(4) : '0.0000';
let url;
if (this.platform.is('ios')) { if (this.platform.is('ios')) {
return 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed; url = 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed;
} else {
url = 'geo:' + northFixed + ',' + eastFixed;
} }
return 'geo:' + northFixed + ',' + eastFixed; return this.sanitizer.bypassSecurityTrustUrl(url);
} }
} }

View File

@ -68,7 +68,13 @@ export class CoreMimetypeUtilsProvider {
} }
// If the extension has parameters, remove them. // If the extension has parameters, remove them.
const position = extension.indexOf('?'); let position = extension.indexOf('?');
if (position > -1) {
extension = extension.substr(0, position);
}
// If the extension has an anchor, remove it.
position = extension.indexOf('#');
if (position > -1) { if (position > -1) {
extension = extension.substr(0, position); extension = extension.substr(0, position);
} }