MOBILE-2201 link: Fix URLs with escaped characters
parent
e4260aa92a
commit
759f0c3624
|
@ -380,7 +380,7 @@ export class CoreFormatTextDirective implements OnChanges {
|
|||
anchors.forEach((anchor) => {
|
||||
// Angular 2 doesn't let adding directives dynamically. Create the CoreLinkDirective manually.
|
||||
const linkDir = new CoreLinkDirective(anchor, this.domUtils, this.utils, this.sitesProvider, this.urlUtils,
|
||||
this.contentLinksHelper, this.navCtrl, this.content, this.svComponent);
|
||||
this.contentLinksHelper, this.navCtrl, this.content, this.svComponent, this.textUtils);
|
||||
linkDir.capture = true;
|
||||
linkDir.ngOnInit();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import { CoreUtilsProvider } from '@providers/utils/utils';
|
|||
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
||||
import { CoreConfigConstants } from '../configconstants';
|
||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
|
||||
/**
|
||||
* Directive to open a link in external browser.
|
||||
|
@ -41,7 +42,8 @@ export class CoreLinkDirective implements OnInit {
|
|||
constructor(element: ElementRef, private domUtils: CoreDomUtilsProvider, private utils: CoreUtilsProvider,
|
||||
private sitesProvider: CoreSitesProvider, private urlUtils: CoreUrlUtilsProvider,
|
||||
private contentLinksHelper: CoreContentLinksHelperProvider, @Optional() private navCtrl: NavController,
|
||||
@Optional() private content: Content, @Optional() private svComponent: CoreSplitViewComponent) {
|
||||
@Optional() private content: Content, @Optional() private svComponent: CoreSplitViewComponent,
|
||||
private textUtils: CoreTextUtilsProvider) {
|
||||
// This directive can be added dynamically. In that case, the first param is the anchor HTMLElement.
|
||||
this.element = element.nativeElement || element;
|
||||
}
|
||||
|
@ -62,12 +64,13 @@ export class CoreLinkDirective implements OnInit {
|
|||
this.element.addEventListener('click', (event) => {
|
||||
// If the event prevented default action, do nothing.
|
||||
if (!event.defaultPrevented) {
|
||||
const href = this.element.getAttribute('href');
|
||||
let href = this.element.getAttribute('href');
|
||||
if (href) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (this.utils.isTrueOrOne(this.capture)) {
|
||||
href = this.textUtils.decodeURI(href);
|
||||
this.contentLinksHelper.handleLink(href, undefined, navCtrl, true, true).then((treated) => {
|
||||
if (!treated) {
|
||||
this.navigate(href);
|
||||
|
|
Loading…
Reference in New Issue