Commit 081562ce authored by jaubourg's avatar jaubourg

Pulls out the callback function in setRequestHeader. Also renames the regexp...

Pulls out the callback function in setRequestHeader. Also renames the regexp so that what it's meant to do is a bit more obvious.
parent ea3e10a4
...@@ -15,7 +15,10 @@ var r20 = /%20/g, ...@@ -15,7 +15,10 @@ var r20 = /%20/g,
rselectTextarea = /^(?:select|textarea)/i, rselectTextarea = /^(?:select|textarea)/i,
rspacesAjax = /\s+/, rspacesAjax = /\s+/,
rts = /([?&])_=[^&]*/, rts = /([?&])_=[^&]*/,
rucWord = /(^|\-)([a-z])/g, rucHeaders = /(^|\-)([a-z])/g,
rucHeadersFunc = function( _, $1, $2 ) {
return $1 + $2.toUpperCase();
},
rurl = /^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/, rurl = /^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,
// Keep a copy of the old load method // Keep a copy of the old load method
...@@ -402,9 +405,7 @@ jQuery.extend({ ...@@ -402,9 +405,7 @@ jQuery.extend({
// Caches the header // Caches the header
setRequestHeader: function( name, value ) { setRequestHeader: function( name, value ) {
if ( !state ) { if ( !state ) {
requestHeaders[ name.toLowerCase().replace( rucWord, function( _, $1, $2 ) { requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value;
return $1 + $2.toUpperCase();
} ) ] = value;
} }
return this; return this;
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment