Skip to content

Commit 65895c1

Browse files
committed
Merge pull request #814 from Martii/fixOneTODOinScriptController
Knock out a TODO in the script controller Auto-merge
2 parents f4db626 + 34a9e34 commit 65895c1

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

controllers/script.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,6 @@ exports.view = function (aReq, aRes, aNext) {
403403
// route to edit a script
404404
exports.edit = function (aReq, aRes, aNext) {
405405
//
406-
var authedUser = aReq.session.user;
407-
408-
// Support routes lacking the :username. TODO: Remove this functionality.
409-
aReq.params.username = authedUser.name.toLowerCase();
410-
411406
var installNameSlug = scriptStorage.getInstallName(aReq);
412407
var isLib = aReq.params.isLib;
413408

@@ -434,6 +429,7 @@ exports.edit = function (aReq, aRes, aNext) {
434429

435430
//
436431
var options = {};
432+
var authedUser = aReq.session.user;
437433
var script = null;
438434
var scriptGroups = null;
439435
var tasks = [];

libs/modelParser.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,7 @@ var getScriptViewSourcePageUrl = function (aScript) {
9393
};
9494

9595
var getScriptEditAboutPageUrl = function (aScript) {
96-
var isLib = aScript.isLib || false;
97-
var scriptPath = aScript.installName
98-
.replace(isLib ? /\.js$/ : /\.user\.js$/, '');
99-
var editUrl = scriptPath.split('/');
100-
editUrl.shift();
101-
return (isLib ? '/lib/' : '/script/') + editUrl.join('/') + '/edit';
96+
return getScriptPageUrl(aScript) + '/edit';
10297
};
10398

10499
var getScriptEditSourcePageUrl = function (aScript) {

routes.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ module.exports = function (aApp) {
5858

5959
// Script routes
6060
aApp.route('/scripts/:username/:namespace?/:scriptname').get(script.view);
61-
aApp.route('/script/:username/:namespace?/:scriptname/edit').get(authentication.validateUser, script.edit).post(authentication.validateUser, script.edit);
62-
aApp.route('/script/:namespace?/:scriptname/edit').get(authentication.validateUser, script.edit).post(authentication.validateUser, script.edit);
61+
aApp.route('/scripts/:username/:namespace?/:scriptname/edit').get(authentication.validateUser, script.edit).post(authentication.validateUser, script.edit);
6362
aApp.route('/scripts/:username/:namespace?/:scriptname/source').get(user.editScript);
6463
aApp.route('/scripts/:username').get(function (aReq, aRes) {
6564
aRes.redirect('/users/' + aReq.params.username + '/scripts');
@@ -74,8 +73,7 @@ module.exports = function (aApp) {
7473

7574
// Library routes
7675
aApp.route('/libs/:username/:scriptname').get(script.lib(script.view));
77-
aApp.route('/lib/:scriptname/edit').get(authentication.validateUser, script.lib(script.edit));
78-
aApp.route('/lib/:scriptname/edit').post(authentication.validateUser, script.lib(script.edit));
76+
aApp.route('/libs/:username/:scriptname/edit').get(authentication.validateUser, script.lib(script.edit)).post(authentication.validateUser, script.lib(script.edit));
7977
aApp.route('/libs/:username/:scriptname/source').get(script.lib(user.editScript));
8078
aApp.route('/libs/src/:username/:scriptname').get(scriptStorage.sendScript);
8179

0 commit comments

Comments
 (0)