How to do a branch deploy when it is a branch containing / (slash)

I want to publish multiple Bitbuket branches simultaneously using branch deploy Netlify feature.
However, there is an issue related to accessing the published feature branch.

Here I added my feature branch

I access my main website using
mywebsite.netlify.com

develop branch with
develop--mywebsite.netlify.com

Now, how can I access feature/blog branch? (as there is a slash in it)
feature/blog–mywebsite.netlify.com is an invalid url

@khorotyanvahagn, welcome to our community site. The answer is: we convert the branch to a “slug” format.

In this most cases, any character which isn’t valid in a URL it turned into a literal - (a dash or minus symbol). So, for the example above the URL would be:

https://feature-blog--mywebsite.netlify.com/

Note, there is a double dash between the branch “slug” and the site subdomain.

1 Like

Dear @luke,
I just tried to do as you told me to and it worked. Thank you a lot for the help and for the warm welcome :))

1 Like

I’m trying to do a branch deploy containing a slash using a build hook but I haven’t been able to successfully run a build. I’m using curl and have tried several things like url encoding but it seems Netlify always already encodes the branch name but not decodes it so it never works. Could you advise on how to do this?

CURL command:
curl --location --request POST 'https://api.netlify.com/build_hooks/<hash>?trigger_branch=feature/test-ci&trigger_title=Branch%20test%20deploy'

Results in:

12:42:26 PM: git ref refs/heads/feature&#x2F;test-ci does not exist or you do not have permission
12:42:26 PM: Failing build: Failed to prepare repo
12:42:26 PM: failed during stage 'preparing repo': git ref refs/heads/feature&#x2F;test-ci does not exist 

Thanks for your help!

The branch you are trying to deploy contains a slash, but you cannot make api requests to it?
Did I understand your question correctly?

If so, then if your netlify url is
https://floris.netlify.com
and your branch is feature/test, then the branch url will be
https://feature-test--floris.netlify.com

You access your branch url by adding the branch before your netlify url and adding two dashes – before it
branch--netlifyUrl
And if the branch contains a slash or any other character that an api request cannot understand, in this case " / " (slash), then replace it with " - " (dash)
feature/test -> feature-test

1 Like

Hi @khorotyanvahagn! Thanks for your help but I’m looking for something else. I know how to access a branch deploy containing special characters but at this point I can’t even get the build itself to work properly so there’s no URL to visit. I want to trigger a branch deploy using a build hook with a trigger_branch containing a /.

Any help is greatly appreciated.

1 Like

Hi @floris10hove. Sorry, I got your question wrong.
Unfortunately I haven’t used the feature.
I would recommend posting your question as I do not think people would notice your question here because I marked my question solved. Post it and someone who knows the answer will answer for sure.
Good Luck ))

Alright, thanks for your help. I’ve created a new topic.

1 Like