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

Added versioning for JS files - avoid cache issues #1644

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update require.js
  • Loading branch information
SpoorthiNaidu authored Mar 10, 2017
commit 072a97d93d482a8ef31f3400ff45c86acc62fdbe
15 changes: 12 additions & 3 deletions require.js
Original file line number Diff line number Diff line change
Expand Up @@ -1624,8 +1624,9 @@ var requirejs, require, define;
*/
nameToUrl: function (moduleName, ext, skipExt) {
var paths, syms, i, parentModule, url,
parentPath, bundleId,
pkgMain = getOwn(config.pkgs, moduleName);
parentPath, bundleId, pathSplit,
pkgMain = getOwn(config.pkgs, moduleName),
versionSuffix = 1;

if (pkgMain) {
moduleName = pkgMain;
Expand Down Expand Up @@ -1658,6 +1659,14 @@ var requirejs, require, define;
parentModule = syms.slice(0, i).join('/');

parentPath = getOwn(paths, parentModule);

// attach version number to js files
if (typeof parentPath === 'string' && parentPath.indexOf('?') != -1) {
pathSplit = parentPath.split('?');
parentPath = pathSplit[0];
versionSuffix = pathSplit[1]
}

if (parentPath) {
//If an array, it means there are a few choices,
//Choose the one that is desired
Expand All @@ -1671,7 +1680,7 @@ var requirejs, require, define;

//Join the path parts together, then figure out if baseUrl is needed.
url = syms.join('/');
url += (ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? '' : '.js'));
url += (ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? '' : '.js?v=' + versionSuffix));
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
}

Expand Down