mojolicious / mojo

:sparkles: Mojolicious - Perl real-time web framework
https://mojolicious.org
Artistic License 2.0
2.66k stars 577 forks source link

Add absolute check to url_for_asset and url_for_file to fix appending "/" to absolute file paths #2112

Closed rawleyfowler closed 12 months ago

rawleyfowler commented 1 year ago

Summary

There is currently a bug where:

%= image('https://www.somesite.com/image.png')

produces

<img src="/https://www.somesite.com/image.png">

This PR adds an absolute check to the file_path and asset_path methods that currently breaks this.

Motivation

This is breaking multiple of my systems in production. (And it seems its breaking others as well)

References

2107

rawleyfowler commented 1 year ago

I haven't seen any constants in Mojolicious (perl), wasn't sure if you'd like to pull the regex to a constant ala Mojo.js, but besides that this should be 1:1 with Mojo.js.

jixam commented 12 months ago

FWIW, I added this patch to our build and our tests started passing again. So, works for me :)