verbb / icon-picker

A Craft CMS field to select SVG or font icons from a folder for use in your content.
Other
17 stars 8 forks source link

iconSetsUrl is treated as a directory path, not a URL #9

Closed michaelroper closed 5 years ago

michaelroper commented 5 years ago

Hey Josh! just a heads up because I just got bit by something similar to #8 ...

Because you are passing the iconSetsUrl variable through the FileHelper::normalisePath function (like here), it actually break the image URL if you set iconSetsUrl to an actual fully qualified URL, because it converts double slashes to a single slash, breaking any https://... in the URL.

tl;dr:

'iconSetsUrl' => '/icons/'

📛 'iconSetsUrl' => getenv('SITE_URL') . 'icons/'

📛 'iconSetsUrl' => 'https://my.file.cdn.com/icons/' (URL becomes https:/my.file.cdn.com/icons/)

engram-design commented 5 years ago

Yeah, I knew normalisePath might not be the proper function for this case. All I wanted was to ensure the path had the proper slashes. As in, these should all be treated the same:

'iconSetsUrl' => 'icons/'
'iconSetsUrl' => 'icons'
'iconSetsUrl' => '/icons'
'iconSetsUrl' => '/icons/'

I'll see if I can throw together a better function for this.

michaelroper commented 5 years ago

hah, yeah.. this is surely a problem that has been solved before? 😛

engram-design commented 5 years ago

Fixed in 1.0.5