-2

I am trying to write a program using ExpressJS. The user should be able to send me an url. But there is an issue. It doesn't work because the user send me the url with an url (using XMLHTTPRequest).

How can I handle urls and get methods which contain an url ? Thank you

Des2207
  • 9
  • 5

1 Answers1

0

You may want to use query parameters instead of url parameters. This would look like so:

http://youhosthere.com/submitUrl/?url=THE_URL_TO_SUBMIT

However this also means, the user has to escape the url he wants to submit. In Javascript for example this can be done by using encodeURIComponent:

encodeURIComponent('THE_URL_TO_SUBMIT')

For further information on encodeURIComponent, you may want to read the mozilla article

With express you can read the query params using req.query.YOUR_QUERY_PARAM as proposed by Marcus Granström here

moronator
  • 304
  • 4
  • 11