lib/nanoc3/data_sources/filesystem_unified.rb in nanoc3-3.2.0a4 vs lib/nanoc3/data_sources/filesystem_unified.rb in nanoc3-3.2.0b1

- old
+ new

@@ -38,12 +38,12 @@ # foo.entry.html → /foo.entry/ # # (`allow_periods_in_identifiers` set to false) # foo.html.erb → /foo/ # - # Note that it is possible for two different, separate files to have the - # same identifier. It is recommended to avoid such situations. + # Note that each item must have an unique identifier. nanoc will display an + # error if two items with the same identifier are found. # # Some more examples: # # content/index.html → / # content/foo.html → /foo/ @@ -101,13 +101,13 @@ end # Returns the identifier derived from the given filename, first stripping # the given directory name off the filename. def identifier_for_filename(filename) - if filename =~ /index\.[^\/]+$/ - regex = ((@config && @config[:allow_periods_in_identifiers]) ? /index\.[^\/\.]+$/ : /index\.[^\/]+$/) + if filename =~ /(^|\/)index\.[^\/]+$/ + regex = ((@config && @config[:allow_periods_in_identifiers]) ? /\/?index\.[^\/\.]+$/ : /\/?index\.[^\/]+$/) else - regex = ((@config && @config[:allow_periods_in_identifiers]) ? /\.[^\/\.]+$/ : /\.[^\/]+$/) + regex = ((@config && @config[:allow_periods_in_identifiers]) ? /\.[^\/\.]+$/ : /\.[^\/]+$/) end filename.sub(regex, '').cleaned_identifier end end