aboutsummaryrefslogtreecommitdiff
path: root/interfaces/http/web
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-03-03 14:36:42 +0100
committerJohn Ankarström <john@ankarstrom.se>2021-03-03 14:36:42 +0100
commit2d149be50f74973965abec8c826fe5576a4f2440 (patch)
tree13861e04acc61d5fb92987a8729ed867eed6c42c /interfaces/http/web
parent27067b4d8e5e854f16e3bdb08c2f63f4250632a8 (diff)
downloadcomb-2d149be50f74973965abec8c826fe5576a4f2440.tar.gz
web: Ensure date is right in post URL
Diffstat (limited to 'interfaces/http/web')
-rw-r--r--interfaces/http/web/web.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/interfaces/http/web/web.rb b/interfaces/http/web/web.rb
index 16492c2..0903bb4 100644
--- a/interfaces/http/web/web.rb
+++ b/interfaces/http/web/web.rb
@@ -5,10 +5,11 @@ class WebInterface < Sinatra::Base
erb :index
end
- get '/:year/:month/:day/:slug' do
- @posts = Post.where(slug: params['slug'])
+ get '/:year/:month/:day/:slug' do |y, m, d, slug|
+ @posts = Post.where(slug: slug)
- if @posts.empty? then
+ date = DateTime.strptime("#{y}-#{m}-#{d}", "%Y-%m-%d")
+ if @posts.empty? or @posts[0].created_at.to_date != date.to_date then
status 404
@title = '404 Not Found'
erb :not_found