0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-28 02:42:39 +00:00

validate thumbnail is URL

This commit is contained in:
Gazook89
2022-11-06 13:17:39 -06:00
parent b6c09683be
commit 970d03a5e4
2 changed files with 9 additions and 1 deletions

View File

@@ -275,7 +275,7 @@ const MetadataEditor = createClass({
<label>thumbnail</label>
<input type='text'
defaultValue={this.props.metadata.thumbnail}
placeholder='my.thumbnail.url'
placeholder='https://my.thumbnail.url'
className='value'
onChange={(e)=>this.handleFieldChange('thumbnail', e)} />
<button className='display' onClick={this.toggleThumbnailDisplay}>

View File

@@ -12,6 +12,14 @@ module.exports = {
thumbnail : [
(value)=>{
return value?.length > 256 ? 'Max URL length of 256 characters.' : null;
},
(value)=>{
try {
Boolean(new URL(value));
return null;
} catch (e) {
return 'Must be a valid URL';
}
}
],
language : [