statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

{{ theme:asset }} always outputs absolute urls #2464

Open wanze opened 4 years ago

wanze commented 4 years ago

Describe the bug

According to the docs, the {{ asset }} tag should output relative urls by default. However, it outputs full urls.

To Reproduce

  1. Add the following tag in your template: {{ theme:asset src="assets/app.js" }}
  2. Check the source code

You'll see that the asset is referenced absolute: https://mydomain.com/themes/mytheme/assets/app.js

Expected behavior

The url to the asset should be relative (/themes/mytheme/assets/app.js) and only be absolute if the parameter absolute is set to true.

Solution

Remove the call to URL::prependSiteUrl in Statamic\Addons\Theme\ThemeTags::themeUrl().

Environment details (please complete the following information):

jackmcdade commented 4 years ago

It only appends the site_url as defined in your system locales setting. Do you have the full domain in there?

wanze commented 4 years ago

Hi @jackmcdade

Yep, I have the full domain in there. I assumed that this would be the expected setup because the docs about localization use full urls: https://docs.statamic.com/localization#locales

Can I use relative urls as well?

Cheers