Skip to content

Conversation

@btoews
Copy link
Contributor

@btoews btoews commented Nov 23, 2014

This PR changes the Ajax URL parsing from using a regex to using an anchor tag. This should be simpler and more reliable.

Fixes #1875
/cc @dmethvin

@btoews
Copy link
Contributor Author

btoews commented Nov 24, 2014

Lost some comments when force-pushing. I'm not sure if this is because I amended the commit rather than rebasing.

@dmethvin
Copy link
Member

dmethvin commented Dec 1, 2014

Ow, some thorny issues here. Unit tests fail because they assert that the URL has not been changed other than removing the hash. There are some other failures but I haven't looked into what's causing them.

The new behavior of changing the URL from relative to absolute in particular might be a problem. Can you run the unit tests locally and recommend a solution? We might, for example, leave the settings.url unchanged except for removing the hash, but keep the new scheme for our internal parsing?

capture

@btoews
Copy link
Contributor Author

btoews commented Dec 1, 2014

I thought I was running CI locally, but apparently not. I'll try again.

@btoews
Copy link
Contributor Author

btoews commented Dec 2, 2014

I updated this PR to only use the new URL parsing for setting crossDomain. It's too bad to not be able to use this for the URL rewriting as well, but I understand that we want to minimize changes.

@btoews
Copy link
Contributor Author

btoews commented Dec 2, 2014

Also, I got CI running locally, and this fixes the failing tests.

@dmethvin
Copy link
Member

dmethvin commented Dec 2, 2014

Thanks @mastahyeti, yeah i wish we could clean up the URL but my gut feeling is that it would break a lot of code. @jaubourg could you take a look as well and give your thoughts? The new approach looks a lot cleaner in any case.

src/ajax.js Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still be using s.url like the code it replaces.

@btoews
Copy link
Contributor Author

btoews commented Dec 9, 2014

I've addressed all the issues that were brought up in review. Is this good to go?

@jaubourg
Copy link
Member

jaubourg commented Dec 9, 2014

LGTM 👍

@jaubourg
Copy link
Member

jaubourg commented Dec 9, 2014

Just wondering why the anchor is created at each call but that's fine either way.

@dmethvin
Copy link
Member

dmethvin commented Dec 9, 2014

i noticed that as well but decided it was better to make sure it was "clean" rather than cache it somehow. document.createElement is pretty fast and this isn't time-critical code.

@gibson042
Copy link
Member

LGTM 👍

@timmywil timmywil added the Ajax label Dec 10, 2014
@dmethvin dmethvin self-assigned this Dec 10, 2014
@dmethvin dmethvin added this to the 1.11.2/2.1.2 milestone Dec 11, 2014
@dmethvin
Copy link
Member

@mastahyeti I was about ready to land this but in running through our supported browsers I'm getting fails in every version of IE. Can you take a look?

@btoews
Copy link
Contributor Author

btoews commented Dec 11, 2014

What is an IE? :trollface:

I just downloaded an IE 11 VM and it looks like they always add the port to a.host, but not for location.host. I'm pretty sure that this is the issue, but I'll double check when I get back to the computer I setup CI on.

@btoews
Copy link
Contributor Author

btoews commented Dec 11, 2014

The Ajax tests in master don't seem to pass in IE10:

screen shot 2014-12-11 at 10 03 12 am

I'm pulling an IE11 VM to try. Regardless though, the changes I just pushed do fix the tests that were failing from the location.host inconsistency.

@mgol
Copy link
Member

mgol commented Dec 11, 2014

@mastahyeti They did pass for us: http://swarm.jquery.org/job/3970. Might be some flakeyness; make sure you use an up-to-date IE10 version as well.

@btoews
Copy link
Contributor Author

btoews commented Dec 11, 2014

Hmm. I just ran Windows updates and I'm seeing the same test failure on master. Same thing in IE11.

@dmethvin
Copy link
Member

Just updated and installed all Windows Updates. I don't see any test fails on master using IE InPrivate Browsing. I have some known incompatible plugins that mess up the results if I don't use InPrivate. Same could be happening for you? In my case I'm pretty sure it's LastPass.

I'll pull the updated PR in a few minutes and see if everything works here.

@btoews
Copy link
Contributor Author

btoews commented Dec 11, 2014

Sorry. I'm I didn't realize that it was using dis/jquery.js and that this wasn't getting rebuilt when I switched to master. This is a problem in my branch.

Ajax: don't use new url parsing for url rewriting

Ajax: cut down on unnecessary variables

Ajax: fix indentation of multi-line statement

Ajax: parse origin URL using an anchor tag too (for IE)

Ajax: some IE fixes.

IE only does URL cleanup on for .href
IE also throws errors for malformed URLs.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This accommodates some weird IE behavior.
screen shot 2014-12-11 at 12 37 47 pm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holy crap. Welcome to our cross-browser hell.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a support comment about that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note sure if this will help, but here's a very similar solution with a giant comment about IE: https://github.com/angular/angular.js/blob/master/src/ng/urlUtils.js#L25

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it seems to boil down to almost the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if this should just fail closed, or cancel the request. If the URL is malformed, the request will end up failing either way...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, did some head-scratching on this one and left it as-is with an enhanced comment.

dmethvin pushed a commit that referenced this pull request Dec 11, 2014
Fixes gh-1875
Closes gh-1880
(cherry picked from commit 5a75278e4c5359e07303fc4d8e78a1cf94f6ad65)

Conflicts:
	src/ajax.js
@dmethvin dmethvin closed this in b091fdb Dec 11, 2014
@dmethvin
Copy link
Member

Whew. This would have been so much easier if we had crummier unit tests and test matrix. 😈 I think both branches are good now, please take a look at the commits above and let me know if anything looks amiss. Thanks @mastahyeti!

@btoews
Copy link
Contributor Author

btoews commented Dec 11, 2014

Thanks for all the help @dmethvin

@mgol mgol modified the milestones: 3.0.0, 1.11.2/2.1.2 Dec 15, 2014
markelog pushed a commit that referenced this pull request Nov 10, 2015
mgol referenced this pull request Jun 8, 2016
All support comments were checked for Edge applicability.
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

Simplify $.ajax parsing using a link element

9 participants