Skip to content

Commit ee648ee

Browse files
authored
Merge pull request #2219 from dpalou/MOBILE-3213
Mobile 3213
2 parents c485afe + 4601df6 commit ee648ee

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/addon/mod/data/fields/latlong/component/latlong.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414
import { Component } from '@angular/core';
1515
import { FormBuilder } from '@angular/forms';
16+
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
1617
import { Platform } from 'ionic-angular';
1718
import { Geolocation, GeolocationOptions } from '@ionic-native/geolocation';
1819
import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component';
@@ -30,8 +31,11 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
3031
north: number;
3132
east: number;
3233

33-
constructor(protected fb: FormBuilder, private platform: Platform, private geolocation: Geolocation,
34-
private domUtils: CoreDomUtilsProvider) {
34+
constructor(protected fb: FormBuilder,
35+
protected platform: Platform,
36+
protected geolocation: Geolocation,
37+
protected domUtils: CoreDomUtilsProvider,
38+
protected sanitizer: DomSanitizer) {
3539
super(fb);
3640
}
3741

@@ -58,16 +62,19 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
5862
* @param east Degrees East.
5963
* @return Link to maps depending on platform.
6064
*/
61-
getLatLongLink(north: number, east: number): string {
65+
getLatLongLink(north: number, east: number): SafeUrl {
6266
if (north !== null || east !== null) {
63-
const northFixed = north ? north.toFixed(4) : '0.0000',
64-
eastFixed = east ? east.toFixed(4) : '0.0000';
67+
const northFixed = north ? north.toFixed(4) : '0.0000';
68+
const eastFixed = east ? east.toFixed(4) : '0.0000';
69+
let url;
6570

6671
if (this.platform.is('ios')) {
67-
return 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed;
72+
url = 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed;
73+
} else {
74+
url = 'geo:' + northFixed + ',' + eastFixed;
6875
}
6976

70-
return 'geo:' + northFixed + ',' + eastFixed;
77+
return this.sanitizer.bypassSecurityTrustUrl(url);
7178
}
7279
}
7380

src/providers/utils/mimetype.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ export class CoreMimetypeUtilsProvider {
6868
}
6969

7070
// If the extension has parameters, remove them.
71-
const position = extension.indexOf('?');
71+
let position = extension.indexOf('?');
72+
if (position > -1) {
73+
extension = extension.substr(0, position);
74+
}
75+
76+
// If the extension has an anchor, remove it.
77+
position = extension.indexOf('#');
7278
if (position > -1) {
7379
extension = extension.substr(0, position);
7480
}

0 commit comments

Comments
 (0)