about summary refs log tree commit diff
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/Components/Form.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/client/src/Components/Form.js b/client/src/Components/Form.js
index 4d10f98..077cb58 100644
--- a/client/src/Components/Form.js
+++ b/client/src/Components/Form.js
@@ -11,18 +11,24 @@ function Form(props) {
         }
     };
 
-    const handleChange = (e) => {
+    const handleChange = e => {
         const userInput = e.target.value;
         const valid = isURL('https://' + userInput);
         setState({value: userInput, valid: valid});
     };
 
+    const handlePaste = e => {
+        e.preventDefault();
+        const pattern = /^https?:\/\//;
+        setState({value: e.clipboardData.getData('Text').replace(pattern, ''), valid: false});
+    };
+
     return (
         <form id="form" onSubmit={(e) => e.preventDefault()}>
             <div className={"input-group" + (state.valid ? "" : " disabled")}>
                 <div className={"input-container" + (state.valid ? "" : " border-r-none")}>
                     <span className="input-field-text">https://</span>
-                    <input className="input-field" required onChange={handleChange}/>
+                    <input className="input-field" required value={state.value} onChange={handleChange} onPaste={handlePaste}/>
                 </div>
                 <Button valid={state.valid} submit={handleSubmit}/>
             </div>