arkon / ng-inline-svg

[Inactive] Angular directive for inserting an SVG file inline within an element.
https://echeung.me/ng-inline-svg/
MIT License
210 stars 88 forks source link

Use base href from <base> tag #48

Closed kravets-levko closed 6 years ago

kravets-levko commented 7 years ago

Hi @arkon!

Can the library use by-default base path from the <base href="..."> tag? I think it makes sense, because using relative URLs, we expect that they'll be resolved in next order:

  1. relative to <base> tag;
  2. relative to current URL path.

Currently the library has more powerful way to specify the base path, but this issue is about defaults.

I'm ready to implement this, but I decided to ask beforehand.

Thanks!

arkon commented 6 years ago

Hi @kravets-levko!

Sorry, this slipped through the cracks that is the black hole of my email inbox.

I think this would be a valuable option to have. If you want to submit a PR, I'd be happy to review it. :)

kravets-levko commented 6 years ago

Hi @arkon! I prepared a PR - arkon/ng-inline-svg/pull/49, and I kindly ask you to review it. Thanks!

kravets-levko commented 6 years ago

A short explanation how I encountered this issue: I have a directory structure like this:

dist/
  index.html
  assets/
     app.bundle.js
     logo.svg
     ...

And there fore index.html contains <base href="/assets/"> - to allow loading resources from proper location. And when using this library like <div [inlineSVG]="'logo.svg'"></div> - it does not load file, because it creates absolute url without prefix from <base> tag - which is a bit confusing.

arkon commented 6 years ago

Published in v5.1.0.