Skip to content

Commit

Permalink
Pulls out the callback function in setRequestHeader. Also renames the…
Browse files Browse the repository at this point in the history
… regexp so that what it's meant to do is a bit more obvious.
  • Loading branch information
jaubourg committed Feb 12, 2011
1 parent ea3e10a commit 081562c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ajax.js
Expand Up @@ -15,7 +15,10 @@ var r20 = /%20/g,
rselectTextarea = /^(?:select|textarea)/i,
rspacesAjax = /\s+/,
rts = /([?&])_=[^&]*/,
rucWord = /(^|\-)([a-z])/g,
rucHeaders = /(^|\-)([a-z])/g,
rucHeadersFunc = function( _, $1, $2 ) {
return $1 + $2.toUpperCase();
},
rurl = /^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,

// Keep a copy of the old load method
Expand Down Expand Up @@ -402,9 +405,7 @@ jQuery.extend({
// Caches the header
setRequestHeader: function( name, value ) {
if ( !state ) {
requestHeaders[ name.toLowerCase().replace( rucWord, function( _, $1, $2 ) {
return $1 + $2.toUpperCase();
} ) ] = value;
requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value;
}
return this;
},
Expand Down

0 comments on commit 081562c

Please sign in to comment.