angular-update-meta
angular-update-meta copied to clipboard
Added automatic identification of "og:url" content through $location
If the content of "og:url" meta is empty, automatically detect the URL using $location.absUrl() service.
Disclaimer I found this change very usefull in my project. But, I'm not JS specialist, so I don't know if this is the best approach to resolve this problem.
This is my first Pull Request in github.
@gustavoramos00 — Thank you for your contribution. Congrats on your first contribution 👍
Just to make sure I understand correctly, if you have:
<meta property="og:url" content="http://some.url"></meta>
you would then use:
<update-meta property="og:url" content=""></update-meta>
in a template to replace it with the absolute url of the current location?
Do I understand correctly? Thanks!
Exactly @jvandemo ! I tested as bellow, don't know if has difference.
<update-meta property="og:url"></update-meta>
Sorry for the delay in reply.
I'm really hesitant on this one. I like the idea but I'm not sure if it is explicit enough.
One may see unexpected side-effects when a website is hosted on multiple domains.
Maybe a more explicit approach where $location.absUrl()
is explicitly specified as the value could be more transparent in case you really want to do this.
Great work on the PR though @gustavoramos00 👍
I'll leave it open for others to share their opinion. If no one else has an interest in this then I will close it in a month.
Thanks again @gustavoramos00!
Good point, @jvandemo. Even whether this behavior occurs only when no URL is provided, it doesn't seem explicit enough. What do you think about add other attribute, like this?
<update-meta property="og:url" use-abs-url="true"></update-meta>
@gustavoramos00 — The attribute is an interesting approach indeed. Curious to hear what others think. Nice work!