mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 00:58:14 -05:00
changed student signup route from /join/TOKEN to /signup/TOKEN
This commit is contained in:
parent
2972c528f4
commit
05e61cc842
4 changed files with 10 additions and 10 deletions
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -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(<IntlStudentRegistration {...props} />, document.getElementById('app'));
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue