diff --git a/spec/classes/article_id_parser_spec.cr b/spec/classes/article_id_parser_spec.cr index 2baef20..044aebf 100644 --- a/spec/classes/article_id_parser_spec.cr +++ b/spec/classes/article_id_parser_spec.cr @@ -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") diff --git a/src/classes/article_id_parser.cr b/src/classes/article_id_parser.cr index 1db19de..639013c 100644 --- a/src/classes/article_id_parser.cr +++ b/src/classes/article_id_parser.cr @@ -10,7 +10,7 @@ class ArticleIdParser def parse(request : HTTP::Request) : Maybe from_params = post_id_from_params(request.query_params) from_path = post_id_from_path(request.path) - from_path.or(from_params) + from_params.or(from_path) end private def post_id_from_path(request_path : String)