federicotdn / verb

Organize and send HTTP requests from Emacs
https://melpa.org/#/verb
GNU General Public License v3.0
540 stars 20 forks source link

Incorrectly overrides the template route #54

Closed agzam closed 4 months ago

agzam commented 1 year ago

If there are multiple templates within the same hierarchy of headings, i.e.,

* Requests                               :verb:
  template https://domain1:8080/rest/

** Cats
    template https://api.thecatapi.com/v1

*** breeds
    GET /breeds

Attempting to send a request for /breeds, tries to use the route: https://api.thecatapi.com/v1/rest//breeds, whereas it should be https://api.thecatapi.com/v1/breeds.

federicotdn commented 1 year ago

This behaviour is currently by-design - the docs desrcribe this to some extent:

Host: The last defined heading's URL host will be used.
Path: All paths will be concatenated, starting with the first heading (i.e. the topmost parent).

I have run into cases however where I re-defined the host part of the URL at some middle point of the Org heading hierarchy, and it is true that the result is a bit unexpected (i.e. the last host, but all the paths appended). Maybe if the host is re-defined at any level, this should effectively reset all other components of the URL as well. This would be a relatively large change in terms of user experience.

agzam commented 1 year ago

But why not fix it? The template always starts with "http|https", right? Can it somehow reset the "topmost parent" if it gets redefined down the route while traversing the headings?

Hmm, wait. I might be missing something else there. Need to consult the code and think of some other use cases.

federicotdn commented 4 months ago

Fixed in https://github.com/federicotdn/verb/commit/88f80c9b7f4d87c35453ac4c33f56d2e64846ba3