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

Preserve data on get without dependency on server header #146

Merged
merged 5 commits into from May 21, 2012

Conversation

anttimattila
Copy link
Contributor

When server doesn't return url in X-PJAX-URL header many tests fail. Mainly due to data parameters not being added to url on GET requests.

This fixes all but redirection and reduces dependency on the response header.

This way test is more accurate and when it fails you can see why.
a.href = url
return a.href
}
options.requestUrl = qualifyURL(settings.url)
Copy link
Contributor

Choose a reason for hiding this comment

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

Theres a parseURL helper already. parseURL(settings.url).href should work.

I think we should avoid setting requestUrl on options, maybe just make a new local for it.

@josh
Copy link
Contributor

josh commented May 21, 2012

Otherwise, I dig it.

@travisbot
Copy link

This pull request passes (merged ed34151 into 73dd1ab).

@travisbot
Copy link

This pull request passes (merged 1185f50 into 73dd1ab).

@@ -165,6 +165,8 @@ var pjax = $.pjax = function( options ) {

if (!fire('pjax:beforeSend', [xhr, settings]))
return false

pjax.requestUrl = parseURL(settings.url).href
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just a local? var requestUrl inside the pjax function scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't it used outside the pjax function scope:

function extractContainer(data, xhr, options) {
var obj = {}

// Prefer X-PJAX-URL header if it was set, otherwise fallback to
// using the original requested url.
obj.url = stripPjaxParam(xhr.getResponseHeader('X-PJAX-URL') || pjax.requestUrl)
...

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, sorry its hard to tell from the diff. I guess the original way assigning it to options make sense then. Sorry for the confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem. I changed it back.

@anttimattila
Copy link
Contributor Author

Not sure what you mean by local. I moved the requestUrl property from options to pjax, is that what you ment?
I made the changes and pushed them to the branch, apparently they also update this pull request.

@josh
Copy link
Contributor

josh commented May 21, 2012

Just a local variable: var requestUrl.

Yeah, just keep pushing to the same branch. No need for another pull.

@travisbot
Copy link

This pull request passes (merged 65f8c7c into 73dd1ab).

josh added a commit that referenced this pull request May 21, 2012
Preserve data on get without dependency on server header
@josh josh merged commit e0d306d into defunkt:master May 21, 2012
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

Successfully merging this pull request may close these issues.

None yet

4 participants