sayem314 / hooman

http interceptor to hoomanize cloudflare requests
https://www.npmjs.com/package/hooman
MIT License
148 stars 18 forks source link

Uses URL constructor to reliably generate the url #25

Open msjonker opened 4 years ago

msjonker commented 4 years ago

This fixes the form submit URL when the request is not to the root path. Using the lastIndexOf "/" will get the last directory, but it always needs to be the root. So, for example, if the page being attempted is https://bouqs.com/flowers/all and the action is /flowers/all, the existing code would generate https://bouqs.com/flowers/flowers/all. The URL constructor can intelligently generate the URL from a given base: https://nodejs.org/api/url.html#url_constructor_new_url_input_base