mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-05-05 10:23:41 -04:00
Revert "Merge pull request #1788 from LLK/revert-1775-hotfix/es6-upgrade"
This reverts commit1b1b396e92
, reversing changes made toa144bab0e6
.
This commit is contained in:
parent
1b1b396e92
commit
590f505a61
185 changed files with 13674 additions and 11618 deletions
|
@ -24,9 +24,9 @@ var FastlyConfigMethods = {
|
|||
*/
|
||||
getViewPaths: function (routes) {
|
||||
return routes.reduce(function (paths, route) {
|
||||
var path = route.routeAlias || route.pattern;
|
||||
if (paths.indexOf(path) === -1) {
|
||||
paths.push(path);
|
||||
var p = route.routeAlias || route.pattern;
|
||||
if (paths.indexOf(p) === -1) {
|
||||
paths.push(p);
|
||||
}
|
||||
return paths;
|
||||
}, []);
|
||||
|
@ -39,7 +39,7 @@ var FastlyConfigMethods = {
|
|||
* 2. /path/:arg([regex]) – :arg is removed, leaving just /path/([regex])
|
||||
*/
|
||||
expressPatternToRegex: function (pattern) {
|
||||
pattern = pattern.replace(/(:\w+)(\([^\)]+\))/gi, '$2');
|
||||
pattern = pattern.replace(/(:\w+)(\([^)]+\))/gi, '$2');
|
||||
return pattern.replace(/(:\w+)/gi, '.+?');
|
||||
},
|
||||
|
||||
|
@ -84,7 +84,7 @@ var FastlyConfigMethods = {
|
|||
return 'redirects/' + route.pattern;
|
||||
},
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns custom vcl configuration as a string that sets the varnish
|
||||
* Time to Live (TTL) for responses that come from s3.
|
||||
*
|
||||
|
|
|
@ -19,8 +19,8 @@ module.exports = function (apiKey, serviceId) {
|
|||
*
|
||||
* @return {string}
|
||||
*/
|
||||
fastly.getFastlyAPIPrefix = function (serviceId, version) {
|
||||
return '/service/' + encodeURIComponent(serviceId) + '/version/' + version;
|
||||
fastly.getFastlyAPIPrefix = function (servId, version) {
|
||||
return '/service/' + encodeURIComponent(servId) + '/version/' + version;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -32,15 +32,15 @@ module.exports = function (apiKey, serviceId) {
|
|||
if (!this.serviceId) {
|
||||
return cb('Failed to get latest version. No serviceId configured');
|
||||
}
|
||||
var url = '/service/'+ encodeURIComponent(this.serviceId) +'/version';
|
||||
var url = '/service/' + encodeURIComponent(this.serviceId) + '/version';
|
||||
this.request('GET', url, function (err, versions) {
|
||||
if (err) {
|
||||
return cb('Failed to fetch versions: ' + err);
|
||||
}
|
||||
var latestVersion = versions.reduce(function (latestVersion, version) {
|
||||
if (!latestVersion) return version;
|
||||
if (version.number > latestVersion.number) return version;
|
||||
return latestVersion;
|
||||
var latestVersion = versions.reduce(function (lateVersion, version) {
|
||||
if (!lateVersion) return version;
|
||||
if (version.number > lateVersion.number) return version;
|
||||
return lateVersion;
|
||||
});
|
||||
return cb(null, latestVersion);
|
||||
});
|
||||
|
@ -63,16 +63,16 @@ module.exports = function (apiKey, serviceId) {
|
|||
var postUrl = this.getFastlyAPIPrefix(this.serviceId, version) + '/condition';
|
||||
return this.request('PUT', putUrl, condition, function (err, response) {
|
||||
if (err && err.statusCode === 404) {
|
||||
this.request('POST', postUrl, condition, function (err, response) {
|
||||
if (err) {
|
||||
return cb('Failed while inserting condition \"' + condition.statement + '\": ' + err);
|
||||
this.request('POST', postUrl, condition, function (e, resp) {
|
||||
if (e) {
|
||||
return cb('Failed while inserting condition "' + condition.statement + '": ' + e);
|
||||
}
|
||||
return cb(null, response);
|
||||
return cb(null, resp);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (err) {
|
||||
return cb('Failed to update condition \"' + condition.statement + '\": ' + err);
|
||||
return cb('Failed to update condition "' + condition.statement + '": ' + err);
|
||||
}
|
||||
return cb(null, response);
|
||||
}.bind(this));
|
||||
|
@ -95,11 +95,11 @@ module.exports = function (apiKey, serviceId) {
|
|||
var postUrl = this.getFastlyAPIPrefix(this.serviceId, version) + '/header';
|
||||
return this.request('PUT', putUrl, header, function (err, response) {
|
||||
if (err && err.statusCode === 404) {
|
||||
this.request('POST', postUrl, header, function (err, response) {
|
||||
if (err) {
|
||||
return cb('Failed to insert header: ' + err);
|
||||
this.request('POST', postUrl, header, function (e, resp) {
|
||||
if (e) {
|
||||
return cb('Failed to insert header: ' + e);
|
||||
}
|
||||
return cb(null, response);
|
||||
return cb(null, resp);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -127,11 +127,11 @@ module.exports = function (apiKey, serviceId) {
|
|||
var postUrl = this.getFastlyAPIPrefix(this.serviceId, version) + '/response_object';
|
||||
return this.request('PUT', putUrl, responseObj, function (err, response) {
|
||||
if (err && err.statusCode === 404) {
|
||||
this.request('POST', postUrl, responseObj, function (err, response) {
|
||||
if (err) {
|
||||
return cb('Failed to insert response object: ' + err);
|
||||
this.request('POST', postUrl, responseObj, function (e, resp) {
|
||||
if (e) {
|
||||
return cb('Failed to insert response object: ' + e);
|
||||
}
|
||||
return cb(null, response);
|
||||
return cb(null, resp);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ module.exports = function (apiKey, serviceId) {
|
|||
this.request('PUT', url, cb);
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Upsert a custom vcl file. Attempts a PUT, and falls back
|
||||
* to POST if not there already.
|
||||
*
|
||||
|
@ -186,16 +186,16 @@ module.exports = function (apiKey, serviceId) {
|
|||
return this.request('PUT', url, content, function (err, response) {
|
||||
if (err && err.statusCode === 404) {
|
||||
content.name = name;
|
||||
this.request('POST', postUrl, content, function (err, response) {
|
||||
if (err) {
|
||||
return cb('Failed while adding custom vcl \"' + name + '\": ' + err);
|
||||
this.request('POST', postUrl, content, function (e, resp) {
|
||||
if (e) {
|
||||
return cb('Failed while adding custom vcl "' + name + '": ' + e);
|
||||
}
|
||||
return cb(null, response);
|
||||
return cb(null, resp);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (err) {
|
||||
return cb('Failed to update custom vcl \"' + name + '\": ' + err);
|
||||
return cb('Failed to update custom vcl "' + name + '": ' + err);
|
||||
}
|
||||
return cb(null, response);
|
||||
}.bind(this));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue