Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Fix Bug 917409 - Trim trailing whitespace on urls passed into add clips
Browse files Browse the repository at this point in the history
  • Loading branch information
mjschranz committed Sep 18, 2013
1 parent 1899b39 commit 43f9d5b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions public/src/editor/media-gallery-editor.js
Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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 );
}
Expand Down
2 changes: 2 additions & 0 deletions public/src/editor/sequencer-editor.js
Expand Up @@ -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() ) {
Expand Down
Expand Up @@ -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 );
Expand Down

0 comments on commit 43f9d5b

Please sign in to comment.