Slash in url parameter

In my custom theme, I want to pass a parameter value containing a “Slash”

The parameter value is: Lab/abc and the route is “http:/mysite.com/tags/tag:Lab/abc”.

  • The trouble is that the “/” between “Lab” & “abc” is considered as a new route. So it tries to reach a non existing route.

So I’ve tried to escape the “” with the “url_encode” function, and it gives me another adress "“http:/mysite.com/tags/tag:Lab%2Fabc” but I’m still reaching a non existing route.

My question is : Is grav support “/” in parameter value ? or is it an advanced settings in Grav?

Thanks for help or suggestion.

Grav should not parse any URL parameter but it does when using the Grav URL parameter notation “key:value”.

A workaround is to use the standard “key=value”.

Hi bleutzinn,

unfortunatly the workaround does not work. “key=value” parameter format drives me to an unkwnown route, even with a regular parameter (no slash in it). Did I miss something?

I assume the page tags exists.

Now when I use

http:/mysite.com/tags/tag:category/something

Grav gives me a 404.

When instead I use

http:/mysite.com/tags?tag=category/something

Grav just goes to the page tags.

@Raph31t , @bleutzinn ,

I don’t think the 404 error is a matter of : or = but the preceding ? in front of the query paramers.

The : or = do however influence how the query is interpreted.

When using http://blog-dev/?tag:mush/room a dump of URI will show:

object: Grav\Common\Uri
url: "http://blog-dev/"
...
*query: "tag:mush/room"
*queries: Array(1)
  tag:mush/room: ""                             <-- note the difference
*params: Array(0)

When using http://blog-dev/?tag=mush/room a dump of URI will show:

object: Grav\Common\Uri
url: "http://blog-dev/"
...
*query: "tag=mush/room"
*queries: Array(1)
  tag: "mush/room"                               <-- note the difference
*params: Array(0)

Conclusion:

  • = gives the correct query parameters

Note:

  • When prepending the querystring with a ?, the plugin 'taxonomylist` won’t work out of the box anymore.

Thanks it does the job. I’ve just change to get the tag value from the “uri.query” function and not the “uri.parameter” function.

Glad you got it working.

Just for future reference, the docs about the URI object distinguishes between ‘URL parameter’ and ‘URL query’. The first being what I call Grav style key:value' or actually '/key:value and the second the standard way: ?key=value.

I noticed in the doc 2 days ago, and started to use the Grav syle, but because of the “/” trouble, I have switched to the standard way.

So you know why Grav has developped its own way ?

No I do not. It looks cool but I doubt that was the only reason

The problematic behavior you encountered is a bug in my opinion. I suggest you open an issue in the Grav core repository so the developers can fix it.