2

I've multiple geo string like geo:0,0q=1+a+bc, and I'm gonna assign this to ng-href of the anchor tag. Like below I'm doing it.

HTML

<a ng-href="{{geoString}}">Location</a> </br>

Above tag is rendering fine on HTML but adding unsafe: string geo:0,0q=1+a+bc inside href attribute

Rendered HTML

<a ng-href="geo:0,0q=12345+jefferson+st" href="unsafe:geo:0,0q=12345+jefferson+st">Location</a>

Plunkr with demonstrating issue.

I don't want unsafe: inside href, Any idea why it is pre-appending unsafe: before geoString & How do i remove it?

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
  • 1
    I believe this will answer your question http://stackoverflow.com/questions/15606751/angular-changes-urls-to-unsafe-in-extension-page – Omri Aharon Mar 07 '15 at 09:10

1 Answers1

2

You need to use aHrefSanitizationWhitelist([regexp]);

regex should match the url of your's So in your case it should be like

 $compileProvider.aHrefSanitizationWhitelist(/^\s*(geo):/);

regEx:- starting with geo followed by ' : '

Please see $compileProvider Documentation for more info.

Plunker

Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
squiroid
  • 13,809
  • 6
  • 47
  • 67