[API] Questions about wildcard blocking for whitelists and blacklists

Hello!

When, I go to Dashboard > Domains, and add a domain with the option Add domain as wildcard checked, the final domain shown in the WebUI has a single backslash on its string.

Example:

  • (\.|^)s\.youtube\.com$
  • (\.|^)video-stats\.l\.google\.com$

But, when I check the output of: /.../admin/api-php?list=regex_<list_name>&auth=<token_id>, I get:

  • (\\.|^)s\\.youtube\\.com$
  • (\\.|^)video-stats\\.l\\.google\\.com$

{"data":[{"id":18,"type":2,"domain":"(\\.|^)s\\.youtube\\.com$","enabled":1,"date_added":1666610508,"date_modified":1680012179,"comment":"","groups":[0]},{"id":19,"type":2,"domain":"(\\.|^)video-stats\\.l\\.google\\.com$","enabled":1,"date_added":1666610517,"date_modified":1680012179,"comment":"","groups":[0]}]}

So, I have the following questions:
1. What file from the GitHub repo contains the regex implementation, so I can take a look how it's working in the background when the user use the user interface, instead of CLI to add a domain with that option checked?
2. I have created the following cmd to do what the Add domain as wildcard option does: echo "%url" | sed 's/^/(.|^)/; s/./\./g; s/$/$/', but don't know if I should modify it to be able to add a second backslash. Or does Pi-hole applies that in the background?

Thank you!