spatie / laravel-google-cloud-storage

Google Cloud Storage filesystem driver for Laravel
https://spatie.be/open-source
MIT License
196 stars 51 forks source link

URL Generation Bug on Windows Systems with Prefixes #97

Open seerazz opened 1 month ago

seerazz commented 1 month ago

We encountered an issue with URL generation on Windows systems. When we specify a prefix (e.g., local/files) in the storage configuration, the generated URLs contain an incorrect path separator (\ instead of /), leading to broken URLs.

examples:

Generated URL:

$disk->url('921/assets.zip')

produce: https://my-domain.com/local/files\921/assets.zip

Temporary Signed URL:

 $signedUrl = $disk->temporaryUrl('921/assets.zip', now()->addMinutes(10));

produce: https://my-domain.com/local/files%5C921/assets.zip?GoogleAccessId=xxx

The expected behavior is that the URL should use forward slashes (/) for both the generated and signed URLs, regardless of the system platform.

Environment: Windows system

This issue only occurs on Windows and seems to be related to how path separators are handled with the prefix option.

Would it be possible to ensure cross-platform compatibility for URL generation?