Merge pull request #4240 from overleaf/ns-trim-urls

Trim outer whitespace when adding file from external URL

GitOrigin-RevId: b85b1aac81a138d7ebc11b36f180468cdf778b8c
This commit is contained in:
Alexandre Bourdin
2021-07-05 17:17:19 +02:00
committed by Copybot
parent 40c7f2dae1
commit 89b031a21a

View File

@@ -22,7 +22,7 @@ export default function FileTreeImportFromUrl() {
// set the name when the URL changes
useEffect(() => {
if (url) {
const matches = url.match(/^https?:\/\/.+\/([^/]+\.(\w+))$/)
const matches = url.match(/^\s*https?:\/\/.+\/([^/]+\.(\w+))\s*$/)
setName(matches ? matches[1] : '')
}
}, [setName, url])
@@ -39,7 +39,7 @@ export default function FileTreeImportFromUrl() {
finishCreatingLinkedFile({
name,
provider: 'url',
data: { url },
data: { url: url.trim() },
})
}