mirror of
https://git.sr.ht/~edwardloveall/scribe
synced 2025-12-10 12:41:23 +00:00
Rearrange article id parsing to be more reliable
The article ID parser looks for a string at the end of a URL path with a bunch of hex digits. But it also has to handle user, tag, and search URLs. * /@ba5eba11 * /tag/0ddba11 * /search?q=ba5eba11 Some URLs are encoded as params. The parser used to look at the result of the path first, then the params. But paths that ended in `global-identity-2` messed that up because `2` is a hex digit at the end of the path. This changes the logic to parse params first and paths second which gets around this.
This commit is contained in:
@@ -78,6 +78,14 @@ describe ArticleIdParser do
|
||||
result.should eq(Monads::Just.new("888888abcdef"))
|
||||
end
|
||||
|
||||
it "parses the post id for global identity 2 redirects" do
|
||||
request = resource_request("/m/global-identity-2?redirectUrl=https%3A%2F%2Fexample.com%2Fmy-post-999999abcdef")
|
||||
|
||||
result = ArticleIdParser.parse(request)
|
||||
|
||||
result.should eq(Monads::Just.new("999999abcdef"))
|
||||
end
|
||||
|
||||
it "returns Nothing if path is a username" do
|
||||
request = resource_request("/@ba5eba11")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user