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:
parent
8939772b12
commit
b3166102c7
1 changed files with 11 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue