From 4549fdb9c5eaabf07024b7a7b5b6780b26e543f6 Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Sat, 22 Sep 2018 21:16:01 +0200 Subject: [PATCH] Redirect broken links to 404 when --no-edit mode is enabled. Resolves #1197. --- lib/gollum/app.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 30366fe8..8d0269c9 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -524,12 +524,17 @@ module Precious elsif file = wiki.file(fullpath, wiki.ref, true) show_file(file) else - not_found unless @allow_editing - page_path = [path, join_page_name(name, ext)].compact.join('/') - redirect to("/create/#{clean_url(encodeURIComponent(page_path))}") + if @allow_editing + page_path = [path, join_page_name(name, ext)].compact.join('/') + redirect to("/create/#{clean_url(encodeURIComponent(page_path))}") + else + @message = "The requested page does not exist." + status 404 + return mustache :error + end end end - + def show_file(file) return unless file if file.on_disk?