Kaynağa Gözat

@uppy/url: trim whitespace around user input (#4143)

Andrew McIntee 2 yıl önce
ebeveyn
işleme
aa7b2e8a08
1 değiştirilmiş dosya ile 5 ekleme ve 5 silme
  1. 5 5
      packages/@uppy/url/src/UrlUI.jsx

+ 5 - 5
packages/@uppy/url/src/UrlUI.jsx

@@ -12,15 +12,15 @@ class UrlUI extends Component {
   }
   }
 
 
   handleKeyPress (ev) {
   handleKeyPress (ev) {
-    const { addFile } = this.props
     if (ev.keyCode === 13) {
     if (ev.keyCode === 13) {
-      addFile(this.input.value)
+      this.handleSubmit()
     }
     }
   }
   }
 
 
-  handleClick () {
+  handleSubmit () {
     const { addFile } = this.props
     const { addFile } = this.props
-    addFile(this.input.value)
+    const preparedValue = this.input.value.trim()
+    addFile(preparedValue)
   }
   }
 
 
   render () {
   render () {
@@ -39,7 +39,7 @@ class UrlUI extends Component {
         <button
         <button
           className="uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Url-importButton"
           className="uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Url-importButton"
           type="button"
           type="button"
-          onClick={this.handleClick}
+          onClick={this.handleSubmit}
         >
         >
           {i18n('import')}
           {i18n('import')}
         </button>
         </button>