Skip to content

Commit

Permalink
fix: url validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreiffers committed Oct 27, 2023
1 parent 536ea4f commit e1d8d25
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { Relation } from '../../../types/enums';
import { getRevisions } from '../../../api/concept-catalog-api';
import { compareVersion } from '../../../utils/version';

const isvalidurl = url => {
const isValidUrl = value => {
try {
url(url);
const url = new URL(value);
return url.protocol === 'http:' || url.protocol === 'https:';
} catch (e) {
return false;
}
return true;
};

const tekstMedSpraakKodeArray = Yup.object()
Expand Down Expand Up @@ -45,7 +45,7 @@ const kilde = Yup.array()
test(value) {
const isRequired = this.parent.forholdTilKilde !== 'egendefinert';

if (isRequired && !isvalidurl(value)) {
if (isRequired && !isValidUrl(value)) {
return this.createError({
message: localization.validationUrl
});
Expand Down

0 comments on commit e1d8d25

Please sign in to comment.