Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

IPv6 address returned from $location.host() does not include the brackets in IE/Edge #16692

Closed
1 of 3 tasks
kelvinau opened this issue Sep 12, 2018 · 3 comments · Fixed by javascript-indonesias/angular.js#117

Comments

@kelvinau
Copy link

I'm submitting a ...

  • bug report
  • feature request
  • other

Current behavior:

For example, when the URL is https://[fd12:3456:789a:74::27], $location.host() returns fd12:3456:789a:74::27 in IE/Edge.

This is because host and hostname of a tag element returns the address without bracket, when we use urlParsingNode, and we use it in urlResolve directly:

return {
href: urlParsingNode.href,
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
host: urlParsingNode.host,
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: (urlParsingNode.pathname.charAt(0) === '/')
? urlParsingNode.pathname
: '/' + urlParsingNode.pathname
};

Expected / new behavior:

$location.host() should return the IPv6 address with the brackets. i.e. [fd12:3456:789a:74::27]

Minimal reproduction of the problem with instructions:

Call $location.host() at a IPv6 address using IE/Edge

AngularJS version: 1.7.4

Browser: [ Edge 42.17134.1.0 | IE 11.228.17134.0 ]

Anything else:

I suggest that we can check if the address is in IPv6 format, and add brackets to it if it doesn't exist. Not necessary to check if it's IE/Edge.

@mgol
Copy link
Member

mgol commented Oct 11, 2018

Thanks for the report, I confirm the issue. This is an IE/Edge bug, EdgeHTML 17 still has it but it's fixed in the Edge preview (future 18), see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/16476907/

mgol added a commit to mgol/angular.js that referenced this issue Oct 11, 2018

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
… IE/Edge

IE 9-11 and Edge 16-17 (fixed in 18 Preview) incorrectly don't wrap IPv6
addresses' hostnames in square brackets when parsed out of an anchor element.

Fixes angular#16692
@mgol
Copy link
Member

mgol commented Oct 11, 2018

PR: #16715

mgol added a commit to mgol/angular.js that referenced this issue Oct 11, 2018

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
… IE/Edge

IE 9-11 and Edge 16-17 (fixed in 18 Preview) incorrectly don't wrap IPv6
addresses' hostnames in square brackets when parsed out of an anchor element.

Fixes angular#16692
Closes angular#16715
mgol added a commit to mgol/angular.js that referenced this issue Oct 11, 2018

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
… IE/Edge

IE 9-11 and Edge 16-17 (fixed in 18 Preview) incorrectly don't wrap IPv6
addresses' hostnames in square brackets when parsed out of an anchor element.

Fixes angular#16692
Closes angular#16715
@kelvinau
Copy link
Author

great!

mgol added a commit to mgol/angular.js that referenced this issue Oct 17, 2018

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
… IE/Edge

IE 9-11 and Edge 16-17 (fixed in 18 Preview) incorrectly don't wrap IPv6
addresses' hostnames in square brackets when parsed out of an anchor element.

Fixes angular#16692
Closes angular#16715
@mgol mgol closed this as completed in b4e409b Oct 18, 2018
mgol added a commit that referenced this issue Oct 18, 2018

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
… IE/Edge

IE 9-11 and Edge 16-17 (fixed in 18 Preview) incorrectly don't wrap IPv6
addresses' hostnames in square brackets when parsed out of an anchor element.

Fixes #16692
Closes #16715
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.