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.

ngResource does not replace parameters in the host #14542

Closed
@bluesliverx

Description

@bluesliverx

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When you use a parameter (i.e. :domain) in the hostname, it is not replaced correctly. Instead, it is kept as the parameter name with the colon intact.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
Here is the broken plunkr using 1.4.5: http://plnkr.co/edit/9m0b2er2P6Gb3Jx9Bppo?p=preview
Here is the working version using 1.4.3: http://plnkr.co/edit/RsI3TgKwcjGEXcTMKoQR?p=preview

What is the expected behavior?
It should replace any parameters in the domain, ignoring IPv6 hosts and ports correctly.

What is the motivation / use case for changing the behavior?
This behavior was standard in ngResource 1.4.3. As of 1.4.5, it changed in order to support IPv6 URLs (see #12512). The fix implemented in that issue was too aggressive and effectively ignores hostnames/domains from parameter replacement.

I make use of this behavior heavily in order to support a multi-tenanted application where the the sub-domain decides the tenant. I am not the only one either: http://stackoverflow.com/questions/32463584/passing-domain-name-as-parameter-with-resource-in-angularjs#

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
1.4.5 is where the issue first appeared (I didn't see a 1.4.4 of ngResource), and 1.4.3 worked correctly as described above.

Other information (e.g. stacktraces, related issues, suggestions how to fix)
I think if we can simply add a regex to catch IPv6 addresses and for all other cases keep the previous behavior, including the same handling of port numbers (if the param contains only numbers, ignore it). I'm not sure of IPv6 syntax, but in the examples given in the linked issue, something as simple as looking for square brackets around the hostname may catch it.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions