Split testing with branches containing backslashes

Does anyone know if its possible to force a split test to a branch containing a backslash?

I’ve been experimenting with Netlify’s split testing feature more and stumbled upon this pro tip from @philhawksworth on setting up a “private beta” using the split testing feature by setting the nf_ab cookie to the name of your branch you want to serve the beta, and redirecting your branch deploy back to your production branch deploy.

I organize my branches into groups using backslashes like betas/<branch-name> which seem to deploy to netlify just fine with the branch name being “slugified”, however once a split test is created, setting the split test cookie to something like betas/beta-1 or betas-beta1 doesn’t force the branch to appear.

Does Netlify’s split testing feature not handle forcing a branch with a slash via a cookie? Or is there a special way I should go about setting this up?

Hiya @noelforte and welcome!

We do indeed for some characters like / into - for some purposes - for instance, we can’t have a hostname like anything/anything–sitename.netlify.com so we can’t “present” a branch in that format by hostname. I’m not quite certain how this behavior interacts with split testing, though! Mind telling me your sitename so I can examine the setup in place to see if I have better advice once I see your pattern?

Hey @fool, I went ahead and was able to reproduce the behavior on a quick demo site I spun up. The URL is: https://forte-split-tests.netlify.com/ with 2 branches: split-test-a and tests/split-test-b. I also added 2 lines at the top of the page that show what branch deploy is being served.

Overriding the nf_ab cookie to split-test-a as shown below forces split-test-a to appear…

…but setting the cookie to either tests-split-test-b or tests/split-test-b doesn’t force the other branch to appear.

I’ve also tried escaping the slash to get tests%2Fsplit-test-b but that doesn’t trigger the CDN to display the other branch either. Anything I might be missing on how to get this working or should I stray away from naming my branch deploys with slashes?

1 Like

I think you’ve done all my homework for me! I’ll get a bug filed, but wouldn’t anticipate the feature changing behavior very soon so probably best not to use metacharacters (anything you wouldn’t put in a hostname - things like dots, slashes, spaces, other non-alphanum/dash characters - and also all lowercase letters) for best functionality today.

@fool Hey Chris, thanks for your reply. I’ll probably stick to using dashes as delimiters in my branch names for now until this bug is patched, however long that might take.

In the meantime, I did one more test out of curiosity with a branch name containing an underscore. It appears that the CDN has no issue taking a nf_ab cookie with a value containing an underscore and knows to serve the corresponding branch, so that’s interesting. However, for stability’s sake, alphanumeric characters are probably the most reliable.

Thanks for all your help!