1

I have a urls that look something like this:

/foo/bar/main:home
/foo/bar/main:about_us
/foo/bar/main:contact_us

As you can see I have : in the url, that needs to be taken into consideration. What I want is to match component Home to /foo/bar/main:home, but any other path /foo/bar/main:XXXXX to match component Default.

What I have tried so far:

<Route path={'/foo/bar/main:home'} component={Home} />
<Route path={'/foo/bar/main:any'} component={Default} />

This matches the Home component all the time.

<Route path={'/foo/bar/main%3Ahome'} component={Home} />
<Route path={'/foo/bar/main:any'} component={Default} />

Now, Default is matched all the time. Any help would be appreciated. Thanks.

Amir
  • 4,211
  • 4
  • 23
  • 41

1 Answers1

3

React-router uses path-to-regexp. So to escape : I think this would work:

/foo/bar/main\\:contact_us
Tomasz Mularczyk
  • 34,501
  • 19
  • 112
  • 166