lib/lotus/utils/path_prefix.rb in lotus-utils-0.5.2 vs lib/lotus/utils/path_prefix.rb in lotus-utils-0.6.0
- old
+ new
@@ -78,13 +78,16 @@
# path_prefix.relative_join('new').to_s # => 'posts/new'
# path_prefix.relative_join('new', '_').to_s # => 'posts_new'
def relative_join(strings, separator = @separator)
raise TypeError if separator.nil?
prefix = @string.gsub(@separator, separator)
+ result = [prefix, strings]
+ result.flatten!
+ result.compact!
+ result.reject! {|string| string == separator }
self.class.new(
- [prefix, strings].flatten.compact.join(separator),
- separator
+ result.join(separator), separator
).relative!
end
protected