Fix article ID parsing bug

Since the article ID regular expression wasn't anchored to the end of
the URL, it would grab characters after a / or - that were hex
characters. For example /@user/bacon-123abc would just grab `bac`. Not
great.

This anchors the ID at the end of the string so that it will be more
likely to catch IDs.
This commit is contained in:
Edward Loveall
2022-02-13 21:07:50 -05:00
parent 3f5a5580e0
commit fb51270f87
3 changed files with 10 additions and 1 deletions

View File

@@ -14,6 +14,14 @@ describe ArticleIdParser do
result.should eq(Monads::Just.new("111111abcdef"))
end
it "parses the post id for urls with hex characters after a /" do
request = resource_request("/@user/bacon-abcdef123456")
result = ArticleIdParser.parse(request)
result.should eq(Monads::Just.new("abcdef123456"))
end
it "parses the post id for urls like /user/:post_slug" do
request = resource_request("/user/my-post-222222abcdef")