angular-update-meta icon indicating copy to clipboard operation
angular-update-meta copied to clipboard

Added automatic identification of "og:url" content through $location

Open gustavoramos00 opened this issue 8 years ago • 5 comments

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 avatar May 27 '16 13:05 gustavoramos00

@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!

jvandemo avatar May 27 '16 19:05 jvandemo

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.

gustavoramos00 avatar Jun 01 '16 16:06 gustavoramos00

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!

jvandemo avatar Jul 26 '16 04:07 jvandemo

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 avatar Aug 04 '16 14:08 gustavoramos00

@gustavoramos00 — The attribute is an interesting approach indeed. Curious to hear what others think. Nice work!

jvandemo avatar Aug 30 '16 07:08 jvandemo