Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
ce5784a4
Commit
ce5784a4
authored
Oct 16, 2012
by
Ben Truyman
Committed by
Rick Waldron
Oct 16, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle a falsy URL in the settings object for jQuery.ajax. Fixes #10093, Closes gh-979
parent
fcaef889
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
3 deletions
+39
-3
ajax.js
src/ajax.js
+3
-1
ajax.js
test/unit/ajax.js
+36
-2
No files found.
src/ajax.js
View file @
ce5784a4
...
...
@@ -247,6 +247,7 @@ jQuery.extend({
target
=
jQuery
.
ajaxSettings
;
}
ajaxExtend
(
target
,
settings
);
return
target
;
},
...
...
@@ -557,8 +558,9 @@ jQuery.extend({
// Remove hash character (#7531: and string promotion)
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
// Handle falsy url in the settings object (#10093: consistency with old signature)
// We also use the url parameter if available
s
.
url
=
(
(
url
||
s
.
url
)
+
""
).
replace
(
rhash
,
""
).
replace
(
rprotocol
,
ajaxLocParts
[
1
]
+
"//"
);
s
.
url
=
(
(
url
||
s
.
url
||
ajaxLocation
)
+
""
).
replace
(
rhash
,
""
).
replace
(
rprotocol
,
ajaxLocParts
[
1
]
+
"//"
);
// Extract dataTypes list
s
.
dataTypes
=
jQuery
.
trim
(
s
.
dataType
||
"*"
).
toLowerCase
().
split
(
core_rspace
);
...
...
test/unit/ajax.js
View file @
ce5784a4
...
...
@@ -1451,7 +1451,7 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
jQuery
.
each
(
[
"Same Domain"
,
"Cross Domain"
],
function
(
crossDomain
,
label
)
{
asyncTest
(
"jQuery.ajax() - JSONP, Query String (?n)"
+
label
,
function
()
{
expect
(
4
);
...
...
@@ -1543,7 +1543,7 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
plus
();
}
});
window
[
"jsonpResults"
]
=
function
(
data
)
{
ok
(
data
[
"data"
],
"JSON results returned (GET, custom callback function)"
);
window
[
"jsonpResults"
]
=
undefined
;
...
...
@@ -2725,4 +2725,38 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
expect
(
1
);
ok
(
jQuery
.
active
===
0
,
"ajax active counter should be zero: "
+
jQuery
.
active
);
});
test
(
"jQuery.ajax - falsy url as argument (#10093)"
,
function
()
{
expect
(
4
);
jQuery
.
ajaxSetup
({
timeout
:
0
});
stop
();
jQuery
.
when
(
jQuery
.
ajax
(
""
).
success
(
function
(){
ok
(
true
,
"settings object - empty string"
);
}),
jQuery
.
ajax
(
false
).
success
(
function
(){
ok
(
true
,
"false"
);
}),
jQuery
.
ajax
(
null
).
success
(
function
(){
ok
(
true
,
"null"
);
}),
jQuery
.
ajax
(
undefined
).
success
(
function
(){
ok
(
true
,
"undefined"
);
})
).
always
(
function
()
{
start
();
});
});
test
(
"jQuery.ajax - falsy url in settings object (#10093)"
,
function
()
{
expect
(
4
);
jQuery
.
ajaxSetup
({
timeout
:
0
});
stop
();
jQuery
.
when
(
jQuery
.
ajax
({
url
:
""
}).
success
(
function
(){
ok
(
true
,
"settings object - empty string"
);
}),
jQuery
.
ajax
({
url
:
false
}).
success
(
function
(){
ok
(
true
,
"false"
);
}),
jQuery
.
ajax
({
url
:
null
}).
success
(
function
(){
ok
(
true
,
"null"
);
}),
jQuery
.
ajax
({
url
:
undefined
}).
success
(
function
(){
ok
(
true
,
"undefined"
);
})
).
always
(
function
()
{
start
();
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment