Skip to content

Commit

Permalink
Removes the warning for excessive "/" (#139)
Browse files Browse the repository at this point in the history
Our next/last pagination data includes fields such as "/orgs" so we make
ecessive warnings when really the primary user of this cleanup function
is our own code, in the get_rest_pages function.
  • Loading branch information
mrzarquon authored Mar 30, 2022
1 parent 267c45d commit 0bad67b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pysnyk"
version = "0.9.1"
version = "0.9.2"
description = "A Python client for the Snyk API"
authors = [
"Gareth Rushgrove <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion snyk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get(
Returns a standard requests Response object
"""

path = cleanup_path(path, logger)
path = cleanup_path(path)

url = f"{self.api_url}/{path}"

Expand Down
4 changes: 1 addition & 3 deletions snyk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ def format_package(pkg):
return "{name}@{version}".format(name=pkg.name, version=pkg.version or "*")


def cleanup_path(path: str, logger: logging.Logger) -> str:
def cleanup_path(path: str) -> str:
"""
Strings '/' from the start and end of strings if present to ensure that a '//' doesn't
occur in an API request due to copy/paste error
"""

if path[0] == "/":
logger.warn(f"removing unneccessary leading / from {path}")
path = path[1:]
if path[-1] == "/":
logger.warn(f"removing unneccessary trailing / from {path}")
path = path.rstrip("/")

return path
Expand Down

0 comments on commit 0bad67b

Please sign in to comment.