File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,19 +21,21 @@ function saveToHistory(id: string) {
2121 localStorage . setItem ( HISTORY_KEY , JSON . stringify ( updated ) )
2222}
2323
24+ const VIDEO_ID_RE = / ^ [ a - z A - Z 0 - 9 _ - ] { 11 } $ /
25+
2426const parseVideoId = ( input : string ) : string | null => {
2527 const trimmed = input . trim ( )
28+ const validate = ( id : string | null ) => ( id && VIDEO_ID_RE . test ( id ) ? id : null )
2629 try {
2730 const url = new URL ( trimmed )
2831 if ( url . hostname . includes ( 'youtube.com' ) ) {
29- return url . searchParams . get ( 'v' )
32+ return validate ( url . searchParams . get ( 'v' ) )
3033 }
3134 if ( url . hostname === 'youtu.be' ) {
32- const id = url . pathname . slice ( 1 ) . split ( '?' ) [ 0 ]
33- return id || null
35+ return validate ( url . pathname . slice ( 1 ) . split ( '?' ) [ 0 ] )
3436 }
3537 } catch {
36- if ( / ^ [ a - z A - Z 0 - 9 _ - ] { 11 } $ / . test ( trimmed ) ) return trimmed
38+ return validate ( trimmed )
3739 }
3840 return null
3941}
@@ -198,7 +200,8 @@ const LandingWrapper = styled.div`
198200 display: flex;
199201 flex-direction: column;
200202 align-items: center;
201- padding: 2rem 1.5rem 3rem;
203+ min-height: calc(65vh - 80px);
204+ padding: 6rem 1.5rem 9rem;
202205
203206 @media (max-width: 768px) and (orientation: portrait) {
204207 padding-top: 1.5rem;
You can’t perform that action at this time.
0 commit comments