Parse medium URLs

As far as I can tell, the post id for all medium posts is always 12 hex
characters. We'll find out if that's true.
This commit is contained in:
Edward Loveall 2021-09-04 21:31:48 -04:00
parent 8939772b12
commit b3166102c7
No known key found for this signature in database
GPG key ID: 789A4AE983AC8901

View file

@ -1,7 +1,17 @@
require "json"
class Articles::Show < BrowserAction
get "/posts/:post_id" do
get "/posts/:post_slug" do
id_match = post_slug.match(/([0-9a-f]{12})$/i)
if id_match
post_id = id_match[1]
else
return html(
Errors::ShowPage,
message: "Error parsing the URL",
status: 500,
)
end
if Lucky::Env.use_local?
response = LocalClient.post_data(post_id)
else