Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different relative URLs depending on data binding #259

Open
2 of 8 tasks
SPessall opened this issue Mar 30, 2017 · 2 comments
Open
2 of 8 tasks

Different relative URLs depending on data binding #259

SPessall opened this issue Mar 30, 2017 · 2 comments

Comments

@SPessall
Copy link

SPessall commented Mar 30, 2017

Description

When using relative paths the absolute URL of a generated request seems to be different depending on whether data binding is used.

When using data binding the absolute URL will be relative to the current window location:

    <iron-ajax url="../[[service]]" last-response="{{gateList}}" auto></iron-ajax>

In my case this component generates a request to http://localhost:8080/gate-list if the 'service' property has the value 'gate-list'.

When using a fixed relative URL the resulting absolute URL seems to depend on the source file location.

    <iron-ajax url="../gate-list" last-response="{{gateList}}" auto></iron-ajax>

This component generates a request to http://localhost:8080/src/gate-list, containing an additional level "src/".

Expected outcome

Both variants should generate requests to the same absolute URL.

Actual outcome

The absolute URLs of the generated requests are different, as noted above.

Browsers Affected

  • Chrome
  • Firefox
  • Safari 9
  • Safari 8
  • Safari 7
  • Edge
  • IE 11
  • IE 10
@azariah001
Copy link

azariah001 commented Nov 1, 2017

Hello

This is specifically an eccentricity of the Polymer binding system and not an error on the part of this component. I've actually encountered this issue before across multiple components, was something of a learning curve, in the beginning. A solution is to bind complete data strings which is good for code specificity and allows for easier debugging if you ever change site structure. The reason for this behavior is that when you enter a binding in front of a property the operation doesn't take into account any other characters inside of the binding string it literally just binds in a property = binding way, not in the expected format string way property = `../${binding}`.

On a related topic I'm somewhat surprised that you're able to use relative links at all as it was my understanding that xhr only supported absolute values that included the domain and protocol, and in fact I just wrote a monolithic _urlChanged Observer for iron-ajax that I'm using in my project to handle all of the possible URL formats that can be used.

EDIT: Excuse me while I go eat my hat... 😨 About the only potentially useful thing I wrote in my observer might be the automatic upgrading of HTTP URL's when attempted to be used in a HTTPS page. But other than that.... dumb dumb here wasted 2 hours.... I swear the way I'm now doing my links wasn't working last I checked... url="/query". Well, learning things every day.

@stramel
Copy link
Contributor

stramel commented Jan 24, 2018

I'm not able to reproduce, can one of you provide a jsfiddle or plunker that can reproduce this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants