@@ -183,27 +183,29 @@ func resolveGitRefSource(raw, revision, filePath string, opts summaryOpts) (comp
183183}
184184
185185func resolveURLSource (raw string , opts summaryOpts ) (comparisonSource , error ) {
186+ display := sanitizeURLLabel (raw )
187+
186188 resp , err := httpGet (raw )
187189 if err != nil {
188- return comparisonSource {}, fmt .Errorf ("error downloading file '%s': %w" , raw , err )
190+ return comparisonSource {}, fmt .Errorf ("error downloading file '%s': %w" , display , err )
189191 }
190192 defer resp .Body .Close ()
191193 if resp .StatusCode < http .StatusOK || resp .StatusCode >= http .StatusMultipleChoices {
192- return comparisonSource {}, fmt .Errorf ("error downloading file '%s': unexpected status %s" , raw , resp .Status )
194+ return comparisonSource {}, fmt .Errorf ("error downloading file '%s': unexpected status %s" , display , resp .Status )
193195 }
194196
195197 const maxDownloadSize = 100 << 20 // 100 MB
196198 bits , err := io .ReadAll (io .LimitReader (resp .Body , maxDownloadSize ))
197199 if err != nil {
198- return comparisonSource {}, fmt .Errorf ("error reading downloaded file '%s': %w" , raw , err )
200+ return comparisonSource {}, fmt .Errorf ("error reading downloaded file '%s': %w" , display , err )
199201 }
200202 if len (bits ) == 0 {
201- return comparisonSource {}, fmt .Errorf ("downloaded file '%s' is empty" , raw )
203+ return comparisonSource {}, fmt .Errorf ("downloaded file '%s' is empty" , display )
202204 }
203205
204206 baseURL , err := url .Parse (raw )
205207 if err != nil {
206- return comparisonSource {}, fmt .Errorf ("invalid URL '%s': %w" , raw , err )
208+ return comparisonSource {}, fmt .Errorf ("invalid URL '%s': %w" , display , err )
207209 }
208210 baseURL .Path = path .Dir (baseURL .Path )
209211 baseURL .RawQuery = ""
@@ -230,13 +232,28 @@ func resolveURLSource(raw string, opts summaryOpts) (comparisonSource, error) {
230232 }
231233
232234 return comparisonSource {
233- Display : raw ,
235+ Display : display ,
234236 RootBytes : bits ,
235237 DocConfig : docConfig ,
236238 Cleanup : func () {},
237239 }, nil
238240}
239241
242+ func sanitizeURLLabel (raw string ) string {
243+ if ! isHTTPURL (raw ) {
244+ return raw
245+ }
246+
247+ parsed , err := url .Parse (raw )
248+ if err != nil || parsed == nil {
249+ return raw
250+ }
251+ parsed .User = nil
252+ parsed .RawQuery = ""
253+ parsed .Fragment = ""
254+ return parsed .String ()
255+ }
256+
240257func attachLazyLocalFS (docConfig * datamodel.DocumentConfiguration ) error {
241258 if docConfig == nil || docConfig .BasePath == "" || ! docConfig .AllowFileReferences || docConfig .LocalFS != nil {
242259 return nil
0 commit comments