33import { useState } from 'react' ;
44import { Copy , Check } from 'lucide-react' ;
55
6- export function GoogleDriveUrlConverter ( ) {
6+ export function UrlConverter ( ) {
7+ const [ mode , setMode ] = useState < 'google-drive' | 'custom-domain' > ( 'google-drive' ) ;
78 const [ inputUrl , setInputUrl ] = useState ( '' ) ;
89 const [ inputPassword , setInputPassword ] = useState ( '' ) ;
910 const [ outputUrl , setOutputUrl ] = useState ( '' ) ;
@@ -40,15 +41,46 @@ export function GoogleDriveUrlConverter() {
4041 const handleInputChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
4142 const value = e . target . value ;
4243 setInputUrl ( value ) ;
43- extractAndConvert ( value ) ;
44+ if ( mode === 'google-drive' ) {
45+ extractAndConvert ( value ) ;
46+ } else {
47+ // For custom domain, just update the output URL directly
48+ let customUrl = value ;
49+ if ( inputPassword && inputPassword . length > 0 ) {
50+ const encoded = encodeBase64Utf8 ( inputPassword ) ;
51+ if ( encoded ) customUrl = `${ customUrl } #${ encoded } ` ;
52+ }
53+ setOutputUrl ( customUrl || '' ) ;
54+ }
4455 setCopied ( false ) ;
4556 } ;
4657
4758 const handlePasswordChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
4859 const value = e . target . value ;
4960 setInputPassword ( value ) ;
5061 // Recompute output using the existing URL and new password
51- if ( inputUrl ) extractAndConvert ( inputUrl ) ;
62+ if ( inputUrl ) {
63+ if ( mode === 'google-drive' ) {
64+ extractAndConvert ( inputUrl ) ;
65+ } else {
66+ // For custom domain, recompute with new password
67+ let customUrl = inputUrl ;
68+ if ( value && value . length > 0 ) {
69+ const encoded = encodeBase64Utf8 ( value ) ;
70+ if ( encoded ) customUrl = `${ inputUrl } #${ encoded } ` ;
71+ }
72+ setOutputUrl ( customUrl || '' ) ;
73+ }
74+ }
75+ setCopied ( false ) ;
76+ } ;
77+
78+ const handleModeChange = ( e : React . ChangeEvent < HTMLSelectElement > ) => {
79+ const newMode = e . target . value as 'google-drive' | 'custom-domain' ;
80+ setMode ( newMode ) ;
81+ setInputUrl ( '' ) ;
82+ setInputPassword ( '' ) ;
83+ setOutputUrl ( '' ) ;
5284 setCopied ( false ) ;
5385 } ;
5486
@@ -62,18 +94,42 @@ export function GoogleDriveUrlConverter() {
6294
6395 return (
6496 < div className = "rounded-lg border border-fd-border bg-fd-card p-6 my-6" >
65- < h3 className = "font-semibold mb-4" > Google Drive Direct Link Converter</ h3 >
97+ < h3 className = "font-semibold mb-4" >
98+ { mode === 'google-drive'
99+ ? 'Google Drive Direct Link Converter'
100+ : 'Custom URL Converter' }
101+ </ h3 >
66102
67103 < div className = "space-y-4" >
68104 < div >
69105 < label className = "block text-sm font-medium mb-2" >
70- Paste your Google Drive Share Link:
106+ Conversion Mode:
107+ </ label >
108+ < select
109+ value = { mode }
110+ onChange = { handleModeChange }
111+ className = "w-full px-3 py-2 border border-fd-border rounded-md bg-fd-background text-fd-foreground focus:outline-none focus:ring-2 focus:ring-fd-primary"
112+ >
113+ < option value = "google-drive" > Google Drive Link</ option >
114+ < option value = "custom-domain" > Custom Domain</ option >
115+ </ select >
116+ </ div >
117+
118+ < div >
119+ < label className = "block text-sm font-medium mb-2" >
120+ { mode === 'google-drive'
121+ ? 'Paste your Google Drive Share Link:'
122+ : 'Paste your Custom Domain URL:' }
71123 </ label >
72124 < input
73125 type = "text"
74126 value = { inputUrl }
75127 onChange = { handleInputChange }
76- placeholder = "https://drive.google.com/file/d/YOUR_FILE_ID/view?usp=sharing"
128+ placeholder = {
129+ mode === 'google-drive'
130+ ? 'https://drive.google.com/file/d/YOUR_FILE_ID/view?usp=sharing'
131+ : 'https://example.com/path/to/file'
132+ }
77133 className = "w-full px-3 py-2 border border-fd-border rounded-md bg-fd-background text-fd-foreground placeholder-fd-muted-foreground focus:outline-none focus:ring-2 focus:ring-fd-primary"
78134 />
79135 </ div >
0 commit comments