Also allow blog fid's to remove double dashes

This commit is contained in:
Noah 2016-06-08 20:30:26 +00:00
parent 3eb8e74e54
commit 753b84cdf1

View File

@ -103,10 +103,17 @@ def entry(fid):
# or end, and remove them and see if we have a match. This allows for # or end, and remove them and see if we have a match. This allows for
# fixing blog fid's that allowed leading/trailing dashes and having the # fixing blog fid's that allowed leading/trailing dashes and having the
# old URL just redirect to the new one. # old URL just redirect to the new one.
post_id = Blog.resolve_id(fid.strip("-"), drafts=True) fid = fid.strip("-")
post_id = Blog.resolve_id(fid, drafts=True)
# If still nothing, try consolidating extra dashes into one.
if not post_id:
fid = re.sub(r'-+', '-', fid)
post_id = Blog.resolve_id(fid, drafts=True)
# Did we find one now?
if post_id: if post_id:
# Got one! Redirect to it. return redirect(url_for(".entry", fid=fid))
return redirect(url_for(".entry", fid=fid.strip("-")))
flash("That blog post wasn't found.") flash("That blog post wasn't found.")
return redirect(url_for(".index")) return redirect(url_for(".index"))