From 262e976790fa15358cd234626d558c31f19d5434 Mon Sep 17 00:00:00 2001 From: Thomas Ritz Date: Sat, 21 Feb 2015 19:07:17 +0100 Subject: [PATCH] Fixes computation of `parent`. If there is a file without a basename in root, e.g. `.htaccess`, `#parent` of another file in root finds `.htaccess` instead of `index.html`. Adding the `.htaccess` to the traversal-app fixture exposes this error. The fix is to no longer scan for possible files if we know the parent must be root. --- middleman-core/fixtures/traversal-app/source/.htaccess | 0 .../lib/middleman-core/sitemap/extensions/traversal.rb | 4 +++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 middleman-core/fixtures/traversal-app/source/.htaccess diff --git a/middleman-core/fixtures/traversal-app/source/.htaccess b/middleman-core/fixtures/traversal-app/source/.htaccess new file mode 100644 index 00000000..e69de29b diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb b/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb index 729a6204..d5232c47 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb @@ -9,7 +9,9 @@ module Middleman tail = parts.pop is_index = (tail == app.index_file) - return nil if is_index && parts.length < 1 + if parts.empty? + return is_index ? nil : store.find_resource_by_path(app.index_file) + end test_expr = parts.join('\\/') # A makeshift for eponymous reverse-lookup