Snake Filter - punctuation such as slashes and colons do not get replaced
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
Description
When using the snake filter in Craft 3, some of the punctuation such as dots, slashes and colons do not get replaced with underscores. Is there a known solution to solve this when moving code from C2 to C3.
If I output the following twig template code for example.
{% set example = "https://example.com/hello-world-dash" %}
{{ example|snake }}
{{ "https://another-example.com/hello-world-dash"|snake }}
It will display like below
https://example.com/hello_world_dash
https://another_example.com/hello_world_dash
Instead of
https_example_com_hello_world_dash
https_another_example_com_hello_world_dash
A similar ticket can be found here but no responses - https://github.com/craftcms/cms/issues/5870
Steps to reproduce
- Use a URL and apply Snake filter
- Output will show slashes and colons etc
Additional info
- Craft version: 3.5.8
- PHP version: 7.4.X
- Database driver & version:
- Plugins & versions:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in a Twig template with the documented URL examples and the snake filter on Craft 3.5.8. Trace the snake filter's punctuation handling and compare it with the expected underscore output; done means dots, slashes, and colons are replaced while existing hyphen handling remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100