Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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
javascript-indonesias/angular.js
#117
@kelvinau

Description

@kelvinau

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions