From eac11510663e237279d2e634c1b43da32973732c Mon Sep 17 00:00:00 2001 From: Karishma Chadha <kchadha@scratch.mit.edu> Date: Sun, 25 Feb 2018 21:45:39 -0500 Subject: [PATCH] Minor update to regex for url validation. --- src/containers/import-modal.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/containers/import-modal.jsx b/src/containers/import-modal.jsx index cb5b169bc..1c2ddbefb 100644 --- a/src/containers/import-modal.jsx +++ b/src/containers/import-modal.jsx @@ -51,13 +51,13 @@ class ImportModal extends React.Component { this.setState({inputValue: e.target.value, hasValidationError: false}); } validate (input) { - const urlMatches = input.match(/^(https:\/\/)?scratch\.mit\.edu\/projects\/(\d+)/); + const urlMatches = input.match(/^(?:https:\/\/)?scratch\.mit\.edu\/projects\/(\d+)/); if (urlMatches && urlMatches.length > 0) { - return urlMatches[2]; + return urlMatches[1]; } - const projectIdMatches = input.match(/^(#?)(\d+)$/); + const projectIdMatches = input.match(/^#?(\d+)$/); if (projectIdMatches && projectIdMatches.length > 0) { - return projectIdMatches[2]; + return projectIdMatches[1]; } return null; } -- GitLab