From 05e61cc842cb3b885f2f5236469ca789e6ddb35a Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Tue, 7 Apr 2020 14:27:07 -0400 Subject: [PATCH] changed student signup route from /join/TOKEN to /signup/TOKEN --- src/lib/route.js | 8 ++++---- src/routes.json | 4 ++-- src/views/studentregistration/studentregistration.jsx | 2 +- test/unit/lib/route.test.js | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/route.js b/src/lib/route.js index 4eee7620d..ebd94762f 100644 --- a/src/lib/route.js +++ b/src/lib/route.js @@ -6,10 +6,10 @@ module.exports.getURIClassroomToken = uriPathname => { const classRegisterRegexp = /^\/?classes\/\d*\/register\/([a-zA-Z0-9]*)\/?$/; const classRegisterMatch = classRegisterRegexp.exec(uriPathname); if (classRegisterMatch) return classRegisterMatch[1]; - // if regex match failed, try to match /join/CLASSROOM_TOKEN - const joinTokenRegexp = /^\/?join\/([a-zA-Z0-9]*)\/?$/; - const joinTokenMatch = joinTokenRegexp.exec(uriPathname); - if (joinTokenMatch) return joinTokenMatch[1]; + // if regex match failed, try to match /signup/CLASSROOM_TOKEN + const signupTokenRegexp = /^\/?signup\/([a-zA-Z0-9]*)\/?$/; + const signupTokenMatch = signupTokenRegexp.exec(uriPathname); + if (signupTokenMatch) return signupTokenMatch[1]; // if neither matched return null; }; diff --git a/src/routes.json b/src/routes.json index 781348730..bc7fde6b1 100644 --- a/src/routes.json +++ b/src/routes.json @@ -282,8 +282,8 @@ }, { "name": "student-registration-token-only", - "pattern": "^/join/:token", - "routeAlias": "/classes/(complete_registration|.+/register/.+)", + "pattern": "^/signup/:token", + "routeAlias": "/signup/.+)", "view": "studentregistration/studentregistration", "title": "Class Registration" }, diff --git a/src/views/studentregistration/studentregistration.jsx b/src/views/studentregistration/studentregistration.jsx index 6605d6145..5b8ff8b39 100644 --- a/src/views/studentregistration/studentregistration.jsx +++ b/src/views/studentregistration/studentregistration.jsx @@ -163,7 +163,7 @@ const IntlStudentRegistration = injectIntl(StudentRegistration); // parse either format of student registration url: // "class register": http://scratch.mit.edu/classes/3/register/c0256654e1be -// "join token": http://scratch.mit.edu/join/c025r54ebe +// "signup token": http://scratch.mit.edu/signup/c025r54ebe const props = {classroomToken: route.getURIClassroomToken(document.location.pathname)}; render(, document.getElementById('app')); diff --git a/test/unit/lib/route.test.js b/test/unit/lib/route.test.js index 2acb17599..98a00cb1b 100644 --- a/test/unit/lib/route.test.js +++ b/test/unit/lib/route.test.js @@ -12,15 +12,15 @@ describe('unit test lib/route.js', () => { expect(response).toEqual('r9n5f5xk'); }); - test('getURIClassroomToken parses URI paths like /join/e2dcfkx95', () => { + test('getURIClassroomToken parses URI paths like /signup/e2dcfkx95', () => { let response; - response = route.getURIClassroomToken('/join/e2dcfkx95'); + response = route.getURIClassroomToken('/signup/e2dcfkx95'); expect(response).toEqual('e2dcfkx95'); }); test('getURIClassroomToken works with trailing slash', () => { let response; - response = route.getURIClassroomToken('/join/r9n5f5xk/'); + response = route.getURIClassroomToken('/signup/r9n5f5xk/'); expect(response).toEqual('r9n5f5xk'); }); });