Fix #1788 incorrect url_for for routes with hosts, added tests. (#1789)

* Fix #1788 incorrect url_for for routes with hosts, added tests.

* Linter

* Remove debug print
This commit is contained in:
L. Kärkkäinen
2020-02-21 19:10:22 +02:00
committed by GitHub
parent 91f6abaa81
commit 861e87347a
2 changed files with 21 additions and 1 deletions

12
tests/test_url_for.py Normal file
View File

@@ -0,0 +1,12 @@
def test_routes_with_host(app):
@app.route("/")
@app.route("/", name="hostindex", host="example.com")
@app.route("/path", name="hostpath", host="path.example.com")
def index(request):
pass
assert app.url_for("index") == "/"
assert app.url_for("hostindex") == "/"
assert app.url_for("hostpath") == "/path"
assert app.url_for("hostindex", _external=True) == "http://example.com/"
assert app.url_for("hostpath", _external=True) == "http://path.example.com/path"