angular / router

The Angular 1 Component Router
MIT License
665 stars 135 forks source link

mailto links are recognized as component routes #345

Open tkrotoff opened 9 years ago

tkrotoff commented 9 years ago

<a href="mailto:hello">Send mail</a> gives URL http://example.com/#/mailto:hello

Debugging: anchorLinkDirective parses the href attribute, recognized it as an internal/component route (if ($router.recognize(href))) and call $router.navigate(href).

mailto links are probably not the only ones affected.

tkrotoff commented 9 years ago

Hackish fix here:

if (href.indexOf('mailto:') != 0 && $router.recognize(href)) {
  $router.navigate(href);
  event.preventDefault();
}

With ES6/TypeScript you can replace href.indexOf('mailto:') != 0 by !href.startsWith('mailto:')

jhunger commented 9 years ago

+1