Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The image helper now produces absolute paths #2107

Closed
jixam opened this issue Sep 18, 2023 · 7 comments
Closed

The image helper now produces absolute paths #2107

jixam opened this issue Sep 18, 2023 · 7 comments
Labels

Comments

@jixam
Copy link
Contributor

jixam commented Sep 18, 2023

  • Mojolicious version: 9.34
  • Perl version: 5.36
  • Operating system: Ubuntu 22.04 LTS

Steps to reproduce the behavior

perl -E 'use Mojolicious; say join ": ", $Mojolicious::VERSION, Mojolicious->new->build_controller->image("test.png")'

Expected behavior

We noticed this change in behavior which does not seem to be mentioned in Changes.

Before we adjust our application we wanted to check that the change is intended?

Actual behavior

Previous output:

9.33: <img src="test.png">

New output:

9.34: <img src="/test.png">
@kraih
Copy link
Member

kraih commented Sep 18, 2023

Yes, this is intentional. The generated URL is supposed to be relative to the static directory of the application.

@kraih kraih closed this as completed Sep 18, 2023
@jixam
Copy link
Contributor Author

jixam commented Sep 19, 2023

All right, thank you for the clarification.

This is quite a breaking change for us as we have been treating the parameter as just the verbatim src attribute, doing things like image("https://example.org/test.png"). But we will cope :)

@kraih
Copy link
Member

kraih commented Sep 19, 2023

Absolute URLs are actually supposed to be passed through unchanged. If that doesn't work currently it would be incompatible with mojo.js and therefore a bug.

@kraih kraih reopened this Sep 19, 2023
@rawleyfowler
Copy link
Contributor

We're effected by this as well, I'll take a crack at a PR.

@rawleyfowler
Copy link
Contributor

Here's an instance of the behavior in one of our projects:

src="/https://reasonml.github.io/img/reason.svg"

@sergiotarxz
Copy link
Contributor

sergiotarxz commented Feb 10, 2024

I am getting to work in this.
PD1: Should I change this behavior in sub _file_url?
PD2: I have done a pull request testing the behavior people said was broken. #2149
PD3: I am under the impression that what I tested only duplicates an existing test from #2112 which tests the inner subroutine instead of the helper image. Maybe this issue should be closed?

@jixam
Copy link
Contributor Author

jixam commented Feb 11, 2024

I will go ahead and close this issue since it was mostly fixed by #2112.

@jixam jixam closed this as completed Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants