mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 13:32:45 +00:00
validate thumbnail is URL
This commit is contained in:
@@ -275,7 +275,7 @@ const MetadataEditor = createClass({
|
|||||||
<label>thumbnail</label>
|
<label>thumbnail</label>
|
||||||
<input type='text'
|
<input type='text'
|
||||||
defaultValue={this.props.metadata.thumbnail}
|
defaultValue={this.props.metadata.thumbnail}
|
||||||
placeholder='my.thumbnail.url'
|
placeholder='https://my.thumbnail.url'
|
||||||
className='value'
|
className='value'
|
||||||
onChange={(e)=>this.handleFieldChange('thumbnail', e)} />
|
onChange={(e)=>this.handleFieldChange('thumbnail', e)} />
|
||||||
<button className='display' onClick={this.toggleThumbnailDisplay}>
|
<button className='display' onClick={this.toggleThumbnailDisplay}>
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ module.exports = {
|
|||||||
thumbnail : [
|
thumbnail : [
|
||||||
(value)=>{
|
(value)=>{
|
||||||
return value?.length > 256 ? 'Max URL length of 256 characters.' : null;
|
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 : [
|
language : [
|
||||||
|
|||||||
Reference in New Issue
Block a user