2

I'm trying to use dot (.) in query string parameter but its not working.

This URL is working fine:

http://localhost:9000/search-result?majTFMin=0&majTFMax=100&majDOMCFMin=0&majDOMCFMax=100&majRefDomainsMin=0&majRefDomainsMax=100&majRefIPsMin=0&majRefIPsMax=100&majRefDomainsEDUMin=0&majRefDomainsEDUMax=100&majRefDomainsGOVMin=0&majRefDomainsGOVMax=100&selectedTLDs=com

But not this one as it contains a dot in a parameter:

http://localhost:9000/search-result?majTFMin=0&majTFMax=100&majDOMCFMin=0&majDOMCFMax=100&majRefDomainsMin=0&majRefDomainsMax=100&majRefIPsMin=0&majRefIPsMax=100&majRefDomainsEDUMin=0&majRefDomainsEDUMax=100&majRefDomainsGOVMin=0&majRefDomainsGOVMax=100&selectedTLDs=co.uk

When I'm trying to open above URL (with dot), it just prints:

Cannot GET /search-result?majTFMin=0&majTFMax=100&majDOMCFMin=0&majDOMCFMax=100&majRefDomainsMin=0&majRefDomainsMax=100&majRefIPsMin=0&majRefIPsMax=100&majRefDomainsEDUMin=0&majRefDomainsEDUMax=100&majRefDomainsGOVMin=0&majRefDomainsGOVMax=100&selectedTLDs=co.uk

And nothing else, not even any HTML tags(has checked that in view source)

I have read lots of posts which says that . can be used in query string without encoding, but I don't understand why its not working here. I think it has some issue with AngularJS.

I'm using ui-router for state change and passed value to controller.

Any help would be appreciated.

1

1 Answer 1

3

If you are using connect-history-api-fallback on your server (like lite-server does), the URLs with a dot are not rewritten by default.

connect-history-api-fallback code

if (parsedUrl.pathname.indexOf('.') !== -1) { logger( 'Not rewriting', req.method, req.url, 'because the path includes a dot (.) character.' ); return next(); } 

Starting with connect-history-api-fallback version 1.2.0 the URLs with dots are allowed and you can solve this problem by using a a rewrite roule

Example

If your URL with dot is /search-result and you angular app lives in the index.html page you can add a rewrite rule to the connect-history-api-fallback like this

rewrites: [ { from: /^\/search-result/, to: 'index.html' } } ] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.