Skip to content

Commit

Permalink
Adding validation for the OAM URL
Browse files Browse the repository at this point in the history
  • Loading branch information
omranlm committed Jul 19, 2023
1 parent 64d6d05 commit c65d724
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const TileServerList = (props) => {
setInputError(false);
const res = await axios.get(url.replace("/{z}/{x}/{y}", ""));

if (!res) {
setInputError("Invalid OAM Link");
return;
}
if (res.error) setInputError(res.error.response.statusText);

props.addImagery(res.data, url);
Expand All @@ -74,7 +78,8 @@ const TileServerList = (props) => {
return res.data;
} catch (e) {
console.log("isError");
setInputError(e);
// setInputError(e);
setInputError("Invalid OAM Link");
} finally {
setLoading(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const DatasetNew = (props) => {
const navigate = useNavigate();
const [oamURL, setOAMURL] = useState();
const { accessToken } = useContext(AuthContext);
const regUrl = /^(https?|chrome):\/\/[^\s$.?#].[^\s]*$/;
const saveDataset = async () => {
try {
const body = {
Expand Down Expand Up @@ -118,7 +119,13 @@ const DatasetNew = (props) => {
console.log("save");
mutate();
}}
disabled={DSName.trim() === "" || !oamURL || isLoading}
disabled={
!oamURL ||
!regUrl.test(oamURL) ||
DSName.trim() === "" ||
!oamURL.endsWith("{z}/{x}/{y}") ||
isLoading
}
>
Create Training Dataset
</Button>
Expand Down

0 comments on commit c65d724

Please sign in to comment.