Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoPress, Invalid VP URL: Handle case when the URL doesn't contain VP GUID #42237

Open
wants to merge 12 commits into
base: trunk
Choose a base branch
from
Prev Previous commit
Next Next commit
Improve test coverage
  • Loading branch information
bogiii committed Mar 7, 2025
commit 5c7bd9e429ef8e5ef99875f49681420d111162f0
29 changes: 28 additions & 1 deletion projects/packages/videopress/src/client/lib/url/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/**
* Internal dependencies
*/
import { buildVideoPressURL, pickVideoBlockAttributesFromUrl, getVideoNameFromUrl } from '..';
import {
buildVideoPressURL,
pickVideoBlockAttributesFromUrl,
getVideoNameFromUrl,
removeFileNameExtension,
} from '..';

describe( 'buildVideoPressURL', () => {
it( 'should return empty object when invalid URL', () => {
Expand Down Expand Up @@ -142,3 +147,25 @@ describe( 'getVideoNameFromUrl', () => {
);
} );
} );

describe( 'removeFileNameExtension', () => {
it( 'should remove extension from a simple filename', () => {
expect( removeFileNameExtension( 'video.mp4' ) ).toBe( 'video' );
} );

it( 'should remove extension from a filename with multiple dots', () => {
expect( removeFileNameExtension( 'my.awesome.video.mp4' ) ).toBe( 'my.awesome.video' );
} );

it( 'should handle filenames without extension', () => {
expect( removeFileNameExtension( 'video' ) ).toBe( 'video' );
} );

it( 'should handle filenames starting with a dot', () => {
expect( removeFileNameExtension( '.htaccess' ) ).toBe( '' );
} );

it( 'should handle empty string', () => {
expect( removeFileNameExtension( '' ) ).toBe( '' );
} );
} );
Loading