@@ -102,65 +102,14 @@ export function useSourceCode() {
102102 . replace ( '/blob/' , '/' )
103103 }
104104
105- // Generate multiple URL variations to try
106- const urlsToTry : string [ ] = [ ]
107- const filePath = page . value . filePath
108-
109- if ( repoURL . value ) {
110- const baseRawUrl = repoURL . value
111- . replace ( 'github.com' , 'raw.githubusercontent.com' )
112- . replace ( / \/ $ / , '' )
113-
114- // Try different path combinations
115- const pathVariations = [
116- getRepoFilePath . value , // Current computed path
117- filePath , // Original file path without modifications
118- filePath . startsWith ( '/' ) ? filePath . slice ( 1 ) : filePath , // Remove leading slash
119- ]
120-
121- // If current path has docs/, also try without it
122- if ( getRepoFilePath . value . includes ( 'docs/' ) ) {
123- pathVariations . push ( getRepoFilePath . value . replace ( 'docs/' , '' ) )
124- }
125-
126- // If current path doesn't have docs/, also try with it
127- if ( ! getRepoFilePath . value . includes ( 'docs/' ) ) {
128- pathVariations . push ( join ( 'docs' , getRepoFilePath . value ) )
129- }
130-
131- // Generate full URLs for each path variation
132- pathVariations . forEach ( ( path ) => {
133- const cleanPath = path . startsWith ( '/' ) ? path . slice ( 1 ) : path
134- urlsToTry . push ( `${ baseRawUrl } /main/${ cleanPath } ` )
135- } )
136- }
137- else {
138- // Fallback to original logic if no repoURL
139- urlsToTry . push ( rawUrl )
140- }
141-
142- // Remove duplicates
143- const uniqueUrls = [ ...new Set ( urlsToTry ) ]
144-
145- let lastError : Error | null = null
146-
147- for ( const url of uniqueUrls ) {
148- try {
149- const response = await fetch ( url )
150- if ( response . ok ) {
151- const content = await response . text ( )
152- await copy ( content )
153- toast . success ( 'Page content copied to clipboard' )
154- return
155- }
156- lastError = new Error ( `HTTP ${ response . status } : ${ response . statusText } ` )
157- }
158- catch ( error ) {
159- lastError = error as Error
160- }
105+ const response = await fetch ( rawUrl )
106+ if ( ! response . ok ) {
107+ throw new Error ( `HTTP ${ response . status } : ${ response . statusText } ` )
161108 }
162109
163- throw lastError || new Error ( 'All URL attempts failed' )
110+ const content = await response . text ( )
111+ await copy ( content )
112+ toast . success ( 'Page content copied to clipboard' )
164113 }
165114 catch ( error ) {
166115 console . error ( 'Failed to copy markdown content:' , error )
0 commit comments