cdent / gabbi

Declarative HTTP Testing for Python and anything else
http://gabbi.readthedocs.org/
Other
148 stars 34 forks source link

Avoid duplicating prefix when re-using urls #205

Closed cdent closed 7 years ago

cdent commented 7 years ago

If a reponse includes an absolute link, re-using that link as the url in a subsequent test when a prefix is being used in the tests can result in a 404 because the prefix will be duplicated.

This change ensures that the prefix will not be duplicated if the URL already begins with the prefix.

Fixes #165

cdent commented 7 years ago

It's not clear to me if this is the right solution. It breaks when a URL such as /prefix/prefix/foo/bar is actually legit in the system. Is that a problem?

/cc @FND

cdent commented 7 years ago

Note that urlparse.urljoin is not workable for this stuff because it only joins if the second argument doesn't begin with / and the first argument ends with /, which is just not how the concept of "prefix" works.