Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove query param from url

I have the following URL:

http://my.site/?code=74e30ef2-109c-4b75-b8d6-89bdce1aa860

And I want to redirect to:

http://my.site#/homepage

I do that with:

import { push } from 'react-router-redux'

...

dispatch(push('/homepage'))

But react takes me to:

http://my.site/?code=74e30ef2-109c-4b75-b8d6-89bdce1aa860#/homepage

How can I tell React to drop the query param in the browser's address bar without reloading the application?

like image 451
blueFast Avatar asked May 27 '19 11:05

blueFast


1 Answers

With Regular Expression maybe this solution is easier for you:

  var oldURL = 'http://my.site/?code=74e30ef2-109c-4b75-b8d6-89bdce1aa860'
  var newURL = /(http(s?).+)(\?.+)/.exec(oldDomain)[1] + 'homepage'

You can use newURL in your project.

like image 88
uyghurbeg Avatar answered Oct 18 '22 18:10

uyghurbeg