gregjacobs / Autolinker.js

Utility to Automatically Link URLs, Email Addresses, Phone Numbers, Twitter handles, and Hashtags in a given block of text/HTML
MIT License
1.48k stars 238 forks source link

anchor href links are not opening from ios app #269

Closed LogeshGovi closed 5 years ago

LogeshGovi commented 5 years ago

Hi, The href links inside anchor elements doesn't open the link in ios App. However, the links work in Android. The links for telephone number and email is working on both ios and android. Eg.

import { Pipe, PipeTransform } from '@angular/core';
import { link } from 'autolinker';
@Pipe({ name: 'linky' })
export class LinkyPipe implements PipeTransform {
  transform(value: string, options?: any): string {
    return link(value, options);
  }
}

we use the pipe in html as follows

<p innerHTML="text | linky">
</p>

The rendered anchor looks this way:

<p>
<a href="some url" target="_blank" rel="noreferrer noopener">someurl</a>
</p>
gregjacobs commented 5 years ago

Hmm, that's interesting. I don't have a device to test on, but do you know which attribute is causing the problem? Is it the target="_blank"?

LogeshGovi commented 5 years ago

Hi Greg, thank you for responding. Yeah I tested it without the attribute target="_blank" and it works, that means it won't redirect to a new browser page but rather it would make the app user sign out. It does the same for target="_top" A redirect to a new window is essential in this case as it is an App.

gregjacobs commented 5 years ago

Hmm, so are you running a Cordova app, for instance? It's not just a website on mobile safari?

If so, you might need to look into how to open a new window for Cordova links in general. Perhaps there's a special attribute that you need? Or maybe it requires a JavaScript call to a Cordova API that opens the window for you?

LogeshGovi commented 5 years ago

Hi, We can close this ticket as I am looking in the direction of Cordova API calls to make the link work in iOS. Anyhow loads of thanks for the tip!