mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 09:08:07 -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 classRegisterRegexp = /^\/?classes\/\d*\/register\/([a-zA-Z0-9]*)\/?$/;
|
||||||
const classRegisterMatch = classRegisterRegexp.exec(uriPathname);
|
const classRegisterMatch = classRegisterRegexp.exec(uriPathname);
|
||||||
if (classRegisterMatch) return classRegisterMatch[1];
|
if (classRegisterMatch) return classRegisterMatch[1];
|
||||||
// if regex match failed, try to match /join/CLASSROOM_TOKEN
|
// if regex match failed, try to match /signup/CLASSROOM_TOKEN
|
||||||
const joinTokenRegexp = /^\/?join\/([a-zA-Z0-9]*)\/?$/;
|
const signupTokenRegexp = /^\/?signup\/([a-zA-Z0-9]*)\/?$/;
|
||||||
const joinTokenMatch = joinTokenRegexp.exec(uriPathname);
|
const signupTokenMatch = signupTokenRegexp.exec(uriPathname);
|
||||||
if (joinTokenMatch) return joinTokenMatch[1];
|
if (signupTokenMatch) return signupTokenMatch[1];
|
||||||
// if neither matched
|
// if neither matched
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
|
@ -282,8 +282,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "student-registration-token-only",
|
"name": "student-registration-token-only",
|
||||||
"pattern": "^/join/:token",
|
"pattern": "^/signup/:token",
|
||||||
"routeAlias": "/classes/(complete_registration|.+/register/.+)",
|
"routeAlias": "/signup/.+)",
|
||||||
"view": "studentregistration/studentregistration",
|
"view": "studentregistration/studentregistration",
|
||||||
"title": "Class Registration"
|
"title": "Class Registration"
|
||||||
},
|
},
|
||||||
|
|
|
@ -163,7 +163,7 @@ const IntlStudentRegistration = injectIntl(StudentRegistration);
|
||||||
|
|
||||||
// parse either format of student registration url:
|
// parse either format of student registration url:
|
||||||
// "class register": http://scratch.mit.edu/classes/3/register/c0256654e1be
|
// "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)};
|
const props = {classroomToken: route.getURIClassroomToken(document.location.pathname)};
|
||||||
|
|
||||||
render(<IntlStudentRegistration {...props} />, document.getElementById('app'));
|
render(<IntlStudentRegistration {...props} />, document.getElementById('app'));
|
||||||
|
|
|
@ -12,15 +12,15 @@ describe('unit test lib/route.js', () => {
|
||||||
expect(response).toEqual('r9n5f5xk');
|
expect(response).toEqual('r9n5f5xk');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getURIClassroomToken parses URI paths like /join/e2dcfkx95', () => {
|
test('getURIClassroomToken parses URI paths like /signup/e2dcfkx95', () => {
|
||||||
let response;
|
let response;
|
||||||
response = route.getURIClassroomToken('/join/e2dcfkx95');
|
response = route.getURIClassroomToken('/signup/e2dcfkx95');
|
||||||
expect(response).toEqual('e2dcfkx95');
|
expect(response).toEqual('e2dcfkx95');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getURIClassroomToken works with trailing slash', () => {
|
test('getURIClassroomToken works with trailing slash', () => {
|
||||||
let response;
|
let response;
|
||||||
response = route.getURIClassroomToken('/join/r9n5f5xk/');
|
response = route.getURIClassroomToken('/signup/r9n5f5xk/');
|
||||||
expect(response).toEqual('r9n5f5xk');
|
expect(response).toEqual('r9n5f5xk');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue