fix for packages with . in name

This commit is contained in:
crflynn
2018-09-19 20:50:01 -04:00
parent edda426efa
commit a4bf548068
2 changed files with 5 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ def api():
@blueprint.route("/packages/<package>/recent")
def api_downloads_recent(package):
"""Get the recent downloads of a package."""
package = package.replace(".", "-")
category = request.args.get('period')
if category is None:
downloads = RecentDownloadCount.query.\
@@ -53,6 +54,7 @@ def api_downloads_recent(package):
@blueprint.route("/packages/<package>/overall")
def api_downloads_overall(package):
"""Get the overall download time series of a package."""
package = package.replace(".", "-")
mirrors = request.args.get('mirrors')
if mirrors == 'true':
downloads = OverallDownloadCount.query.\
@@ -104,6 +106,7 @@ def api_downloads_system(package):
def generic_downloads(model, package, arg, name):
"""Generate a generic response."""
package = package.replace(".", "-")
category = request.args.get(arg)
if category is not None:
downloads = model.query.\

View File

@@ -61,6 +61,7 @@ def index():
@blueprint.route("/search/<package>", methods=("GET", "POST"))
def search(package):
"""Render the home page."""
package = package.replace(".", "-")
form = MyForm()
if form.validate_on_submit():
package = form.name.data
@@ -91,6 +92,7 @@ def faqs():
@blueprint.route("/packages/<package>")
def package(package):
"""Render the package page."""
package = package.replace(".", "-")
# Recent download stats
recent_downloads = RecentDownloadCount.query.\
filter_by(package=package).all()