htmlredirecthyperlinkhreflocal

How and why could a link (or A tag) HREF with a protocol defined redirect locally?


<a href="https://linkedin.com/company/NAME/" target="_blank">Join Us on LinkedIn</a> 

Above is my link from dev tools with the company name swapped out.

As you can see, the https:// protocol is defined in the href. When I inspect the link and click it from Dev tools it bounces me to the LinkedIn page as it should.

When I click the rendered link within the browser, I hit an error as it tries to redirect locally to:

 https://www.WEBSITE.com/%EF%BB%BF%EF%BB%BFhttps://linkedin.com/company/NAME/ 

which is obviously invalid.

I have never seen an A tag behave this way when the protocol is set, and I'm at a loss as to why this would be happening. We've tried updating the link several times and it keeps trying to find this URL within the local site.

No javascript is acting on these links and we have nearly identical links for other social media sites in the same html block that are also using https protocols and they link externally correctly.

Thanks in advance.


Solution

  • Pay close attention to the %EF%BB%BF%EF%BB%BF part of that URL.

    When you decode it it becomes a pair of U+FEFF : ZERO WIDTH NO-BREAK SPACE [ZWNBSP] (alias BYTE ORDER MARK [BOM]) {BOM, ZWNBSP} characters.

    i.e. There are two non-printing characters between " and the start of the URL.

    Since the URL doesn't start with scheme, the browser treats it as a relative path instead of an absolute URL.