Skip to content

Commit

Permalink
Handle more parenthesis in broken URL redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Jun 8, 2024
1 parent 344edbd commit e4f0e0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ app.use((req, res, next) => {
// /projects/123 to /123 and /https://scratch.mit.edu/projects/123 to /123
path.match(/^\/(?:https:\/\/scratch\.mit\.edu\/)?projects\/(\d+)\/?(?:(editor|fullscreen|embed)\/?)?$/) ||
// /123) to /123
path.match(/^\/(\d+)\/?(?:(editor|fullscreen|embed)\/?)?\)$/)
path.match(/^\/(\d+)\/?(?:(editor|fullscreen|embed)\/?)?\)+$/)
);
if (projectMatch) {
const search = url.parse(req.url).search;
Expand Down
6 changes: 6 additions & 0 deletions test/rewrite-broken.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ it('redirects /id/editor/) to /id', () => {
.set('Host', 'localhost')
.expect('Location', '/104/editor');
});

it('redirects /id)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) to /id', () => {
return request.get('/104))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))')
.set('Host', 'localhost')
.expect('Location', '/104');
});

0 comments on commit e4f0e0f

Please sign in to comment.