From 43f9d5b38362d03f0f9e55d451c6d9d1844609f3 Mon Sep 17 00:00:00 2001 From: Matthew Schranz Date: Tue, 17 Sep 2013 13:51:31 -0400 Subject: [PATCH] Fix Bug 917409 - Trim trailing whitespace on urls passed into add clips --- public/src/editor/media-gallery-editor.js | 7 +++++++ public/src/editor/sequencer-editor.js | 2 ++ .../assets/plugins/sequencer/popcorn.sequencer.js | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/public/src/editor/media-gallery-editor.js b/public/src/editor/media-gallery-editor.js index e7391140..cde90607 100644 --- a/public/src/editor/media-gallery-editor.js +++ b/public/src/editor/media-gallery-editor.js @@ -237,12 +237,17 @@ define( [ "localized", "util/lang", "util/uri", "util/keys", "util/mediatypes", } } + function formatSource( value ) { + return !value ? "" : value.trim().split( " " ).join( "" ); + } + function onAddMediaClick() { // transitionend event is not reliable and not cross browser supported. _cancelSpinner = setTimeout( function() { _loadingSpinner.classList.remove( "hidden" ); }, 300 ); _addBtn.classList.add( "hidden" ); + _urlInput.value = formatSource( _urlInput.value ); addMediaToGallery( _urlInput.value, onDenied ); } @@ -271,11 +276,13 @@ define( [ "localized", "util/lang", "util/uri", "util/keys", "util/mediatypes", if ( clips.hasOwnProperty( key ) ) { clip = clips[ key ]; if ( typeof clip === "object" ) { + clip.source = formatSource( clip.source ); addElements( clip ); } else if ( typeof clip === "string" ) { // Load projects saved with just the url the old way. // Remove it too, so future saves don't come through here. delete clips[ key ]; + clip = formatSource( clip ); // Fire an onSuccess so a new, updated clip is added to clipData. MediaUtils.getMetaData( clip, onSuccess ); } diff --git a/public/src/editor/sequencer-editor.js b/public/src/editor/sequencer-editor.js index b2e34101..02b7d454 100644 --- a/public/src/editor/sequencer-editor.js +++ b/public/src/editor/sequencer-editor.js @@ -384,6 +384,8 @@ define( [ "util/mediatypes", "editor/editor", "util/time", } updateOptions.source[ 0 ] = updateOptions.source[ 0 ] || _popcornOptions.source[ 0 ]; + updateOptions.source[ 0 ] = updateOptions.source[ 0 ].trim().split( " " ).join( "" ); + // Bail early to prevent the same video being reloaded due to butteruid. if ( URI.stripUnique( updateOptions.source[ 0 ] ).toString() === URI.stripUnique( _popcornOptions.source[ 0 ] ).toString() ) { diff --git a/public/templates/assets/plugins/sequencer/popcorn.sequencer.js b/public/templates/assets/plugins/sequencer/popcorn.sequencer.js index 8e6a6505..7ca86c6c 100644 --- a/public/templates/assets/plugins/sequencer/popcorn.sequencer.js +++ b/public/templates/assets/plugins/sequencer/popcorn.sequencer.js @@ -211,6 +211,11 @@ if ( options.denied ) { options.fail(); } + + for ( var i = 0; i < options.source.length; i++ ) { + options.source[ i ] = options.source[ i ].trim().split( " " ).join( "" ); + } + options._clip = Popcorn.smart( options._container, options.source, { frameAnimation: true } ); options._clip.on( "error", options.fail );