Skip to content

Commit

Permalink
feat: display error message when user inputs invalid SAS token format (
Browse files Browse the repository at this point in the history
  • Loading branch information
stew-ro authored May 6, 2020
1 parent 91f0669 commit 9826ca8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/react/components/pages/connections/connectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ export default class ConnectionForm extends React.Component<IConnectionFormProps
errors.providerType.addError("is a required property");
}

if (connection.providerOptions && connection.providerOptions["sas"] && errors.providerOptions["sas"]) {
const urlRegex = new RegExp(/^(\s*)?(https:\/\/)([^\s])+(\s*)?$/);
if (urlRegex.test(connection.providerOptions["sas"])) {
const urlWithQueryRegex = new RegExp(/\?.+\=.+/);
if (!urlWithQueryRegex.test(connection.providerOptions["sas"])) {
errors.providerOptions["sas"].addError("should include SAS token in query");
}
} else {
errors.providerOptions["sas"].addError("should match URI format");
}
}

if (this.state.classNames.indexOf("was-validated") === -1) {
this.setState({
classNames: [...this.state.classNames, "was-validated"],
Expand Down

0 comments on commit 9826ca8

Please sign in to comment.