-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require a proper URL with HTTPS only when adding link #2328
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tror ikke valideringen er helt riktig, jeg får feks lov til å skrive url på formatet: hhttp://nrk.no
e363778
to
8541e33
Compare
const isValidURL = (url: string) => { | ||
try { | ||
new URL(url); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dette holder vel ikke for riktig validering? 🤔
Må det ikke være noe sånt som:
const isValidURL = (url: string) => {
try {
const parsedUrl = new URL(url);
return ["http:", "https:"].includes(parsedUrl.protocol);
} catch {
return false;
}
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hvorfor bruker vi ikke regex, egentlig? Har vi ikke en URL-regex som dekker behovene våre i AutoLinkPlugin
? Kan jo bare dra den ut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forslaget mitt var fordi jeg føler det er lettere å innføre feil validering med regex, men man får jo også muligheten til å tune akkurat hvordan valideringen skal være, så kanskje greit om vi bruker det andre steder!
Valideringen plukker fortsatt ikke opp: |
288009d
to
34a0274
Compare
fixes https://github.com/NDLANO/Issues/issues/4274