Skip to content

Commit 59f8407

Browse files
authored
fix: trim whitespace from video URL before sending to Mux (#451)
Added URL trim when pasting a URL to the plugin
1 parent 8af65f3 commit 59f8407

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/actions/upload.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,17 @@ export function testUrl(url: string): Observable<string> {
242242
if (typeof url !== 'string') {
243243
return throwError(error)
244244
}
245+
const trimmedUrl = url.trim()
245246
let parsed
246247
try {
247-
parsed = new URL(url)
248+
parsed = new URL(trimmedUrl)
248249
} catch (err) {
249250
return throwError(error)
250251
}
251252
if (parsed && !parsed.protocol.match(/http:|https:/)) {
252253
return throwError(error)
253254
}
254-
return of(url)
255+
return of(trimmedUrl)
255256
}
256257

257258
function optionsFromFile(opts: {preserveFilename?: boolean}, file: File) {

src/components/Uploader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export default function Uploader(props: Props) {
274274
event.preventDefault()
275275
event.stopPropagation()
276276
const clipboardData = event.clipboardData || (window as any).clipboardData
277-
const url = clipboardData.getData('text')
277+
const url = clipboardData.getData('text')?.trim()
278278
if (!isValidUrl(url)) {
279279
toast.push({status: 'error', title: 'Invalid URL for Mux video input.'})
280280
return

0 commit comments

Comments
 (0)