mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-04 17:07:22 +00:00
20 lines
429 B
JavaScript
20 lines
429 B
JavaScript
export default function TargetURLSelector ({ theme, setLocation, buildLink }) {
|
|
const urlRE = /^(http|https):\/\/[^ "]+$/
|
|
|
|
const onKeyPress = ({ keyCode, target }) => {
|
|
if (keyCode !== 13) return
|
|
|
|
const url = target.value
|
|
|
|
if (urlRE.test(url)) {
|
|
setLocation(buildLink({ url, theme }))
|
|
}
|
|
}
|
|
|
|
return (
|
|
<input
|
|
type='text'
|
|
placeholder='https://...'
|
|
onKeyPress={onKeyPress} />
|
|
)
|
|
}
|