1

I am trying to send . (dot) as a string to the following aspi call in Nodejs. I am using Angularjs $http object.

I can see that the call is being made with the dot (.) character that I have entered in the search box.

https://localhost:3003/posts/search/.

However, when I see the ajax call through google developer tool, it is making a call as:

https://localhost:3003/posts/search/

How can I pass a dot character?

code is:

return

$http.get('https://localhost:3003/posts/search/.').then(getPostCompleted).catch(function (message) {
                handleException(message);
            });

I don't think I have to btoa or atob on this?

Thanks Am

George Netu
  • 2,758
  • 4
  • 28
  • 49
codebased
  • 6,945
  • 9
  • 50
  • 84

3 Answers3

1

You should use get params using something like :

https://localhost:3003/posts/search?req=.

and get the req params in your code. I know it's not the route your wanted but i think that the dot is a special character that coulnd't be use in the route because it is use for the domain

Mathieu Bertin
  • 1,634
  • 11
  • 11
1

How can I pass a dot character?

String in URLs mush be url-encoded. Raw javascript has a function that does this, but angular.js $http service has special behavior for this.

EDIT :

I can see that the call is being made with the dot (.) character that I have entered in the search box.

https://localhost:3003/posts/search/.

However, when I see the ajax call through google developer tool, it is making a call as:

https://localhost:3003/posts/search/

Chrome must be stripping dots without extension by default. A regex parsing it somewhere maybe.

Community
  • 1
  • 1
Cyril CHAPON
  • 3,556
  • 4
  • 22
  • 40
1

See this about using a dot.

If you want to use GET then you could pass the parameter as a query string i.e

$http.get('https://localhost:3003/posts/search?string=.')
.then(getPostCompleted).catch(function (message) {
    handleException(message);
});

Otherwise you can use POST and add the parameter to the body

$http.post('https://localhost:3003/posts/search', {string: '.'})
.then(getPostCompleted).catch(function (message) {
    handleException(message);
});
Community
  • 1
  • 1
Bagofjuice
  • 282
  • 2
  • 13
  • It will not go any further as my route will match to the wrong one - I have one with /posts/:category and another one is /posts/search/:term - thus when I specify as ?term=. it will go to the first one and it is not the solution. I like the post part though which I was thinking to not to use however not a bad idea considering the post is XSS attack safe too. +1 – codebased May 07 '15 at 11:11