nutgaard / react-router-breadcrumbs

Breadcrumb component for react-router
Other
46 stars 11 forks source link

multiple slashes in my createdHref #210

Closed alecperkey closed 7 years ago

alecperkey commented 7 years ago

https://github.com/nutgaard/react-router-breadcrumbs/blob/master/src/breadcrumbs.js#L29

This was causing an error Failed to execute 'pushState' on 'History': A history state object with URL 'http://foo/bar' cannot be created in a document with origin http://zzz.com...

because my link from createHref function was like //foo/bar

so I changed

.replace(/\/\//g, '/');

to

.replace(/\/\/+/g, '/');

nutgaard commented 7 years ago

Hi, and thanks for the feedback.

If possible, please submit this as a pull request with some tests to ensure that the library doesn't regress in the future.

As a side note, it would be interesting to see how your routes are configured since this could most likely be solved by changing those as well.

nutgaard commented 7 years ago

react-router-breadcrumbs@1.3.0 released. Proposed fix in regex included.