falcon icon indicating copy to clipboard operation
falcon copied to clipboard

CSS Resource with query string

Open Kandax86 opened this issue 1 year ago • 1 comments

Hello, i found an issue in the module with the smarty function appendParamToUrl In very cases its ok but not with google fonts.

Google fonts external resources uses multiple times "family" key in the query string but without considering this as an array. so we have googleurl.com?family=font1&family=font2&family=font3

With your code you are using parse_str which will only return the last family key/value association in result and so skip all previous ones.

then you add the version key.

I fixed it with in SmartyHelperFunctions line 64

if ($query) {
        /*parse_str($query, $queryParams);
        $queryParams[$key] = $value;
        $url = str_replace("?$query", '?' . http_build_query($queryParams), $url);*/
	$url .= '&'.http_build_query(array($key=>$value));

but i dont know why you wanted to parse the query string as we sure we have one by the if($query) check so we just have to concatenate your $key=>$value string to the original url.

Can you tell me if you have another idea or a better way to make it possible?

Thank you.

Kandax86 avatar Aug 31 '22 09:08 Kandax86

Hi @Kandax86

thank you for your issue. I think you are right. There should an option with $query as an array and flag $replace to replace parameter or not with default value set to false 🤔

Oksydan avatar Sep 22 '22 20:09 Oksydan

Hi @Kandax86,

appendParamToUrl has been changed. You can read about it here. It will be available with starter version 3.0.0

Oksydan avatar Nov 08 '22 23:11 Oksydan