Skip to content

Commit b5947ba

Browse files
Jonathan GildevallDVLP
Jonathan Gildevall
authored andcommitted
Modify cacheBuster to not have unnecessary &s
1 parent 5fb1da5 commit b5947ba

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

build/jQueryShim.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,13 @@ var ajax = function ajax(options) {
8787
};
8888

8989
request.withCredentials = options.xhrFields.withCredentials;
90-
var cacheBuster = "&_=" + new Date().getTime();
90+
var cacheBuster = "_=" + new Date().getTime();
9191
if (options.url.indexOf("?") === -1) {
92-
options.url += "?";
93-
}
94-
if (options.url.indexOf("&_=") === -1) {
95-
options.url += cacheBuster;
92+
options.url += "?" + cacheBuster;
93+
} else if (options.url.indexOf("_=") === -1) {
94+
options.url += "&" + cacheBuster;
9695
} else {
97-
options.url.replace(/&_=\d+/, cacheBuster);
96+
options.url.replace(/_=\d+/, cacheBuster);
9897
}
9998
request.open(options.type, options.url);
10099
request.setRequestHeader('content-type', options.contentType);

src/jQueryShim.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ const ajax = function(options) {
8181
};
8282

8383
request.withCredentials = options.xhrFields.withCredentials;
84-
var cacheBuster = "&_=" + new Date().getTime();
84+
var cacheBuster = "_=" + new Date().getTime();
8585
if (options.url.indexOf("?") === -1) {
86-
options.url += "?";
87-
}
88-
if (options.url.indexOf("&_=") === -1) {
89-
options.url += cacheBuster;
90-
}
91-
else {
92-
options.url.replace(/&_=\d+/, cacheBuster);
86+
options.url += "?" + cacheBuster;
87+
} else if (options.url.indexOf("_=") === -1) {
88+
options.url += "&" + cacheBuster;
89+
} else {
90+
options.url.replace(/_=\d+/, cacheBuster);
9391
}
9492
request.open(options.type, options.url);
9593
request.setRequestHeader('content-type', options.contentType);

0 commit comments

Comments
 (0)