Skip to content

Commit

Permalink
Merge pull request #201 from rstudio/trailing-slash
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelizimm authored Oct 27, 2023
2 parents 6a88d23 + 31d3335 commit b9248cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vetiver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,8 @@ def vetiver_endpoint(url: str = "http://127.0.0.1:8000/predict") -> str:
>>> import vetiver
>>> endpoint = vetiver.vetiver_endpoint(url='http://127.0.0.1:8000/predict')
"""
# remove trailing backslash, if it exists
if url[-1] == "/":
url = url[:-1]

return url
8 changes: 8 additions & 0 deletions vetiver/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
VetiverAPI,
vetiver_create_prototype,
InvalidPTypeError,
vetiver_endpoint,
)
from pydantic import BaseModel, conint
from fastapi.testclient import TestClient
Expand Down Expand Up @@ -117,3 +118,10 @@ def test_complex_prototype(complex_prototype_model):

with pytest.raises(InvalidPTypeError):
vetiver_create_prototype(response.json())


def test_vetiver_endpoint():
url_raw = "http://127.0.0.1:8000/predict/"
url = vetiver_endpoint(url_raw)

assert url == "http://127.0.0.1:8000/predict"

0 comments on commit b9248cf

Please sign in to comment.