Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

History.Push(): Request to retain query component “?” even when the query parameter is null/empty #780

Open
SidGulatiMsft opened this issue Mar 18, 2020 · 2 comments

Comments

@SidGulatiMsft
Copy link

http://server/?#fragment seems like a valid syntax (RFC 2234, section 3.6).
However, the createPath module (of History package) removes the query component (?) if the query parameter is null/empty resulting in http://server/#fragment

Following is the code snippet for your reference (This code resides in PathUtils.js) :

var createPath = function createPath(location) {
  var pathname = location.pathname,
      search = location.search,
      hash = location.hash;

  var path = pathname || '/';
  if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search;
  if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash;
  return path;
};

Is there a way we can modify/override this behavior to retain the query component (?)

@pshrmn
Copy link
Contributor

pshrmn commented Mar 18, 2020

What is the use case where you would want an empty query component?

@SidGulatiMsft
Copy link
Author

SidGulatiMsft commented Mar 18, 2020

Hi @pshrmn ,
We have encountered 3rd party solutions that leverages specific route patterns (for instances abc.com?#foo) in their angular router implementation.
Also, as per RFC 2234, section 3.6, it seems to be a valid syntax.

However, because of this issue, the downstream solutions break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants