4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/seiten/slug_builder.rb', line 4
def self.call(page_options, prefix_url='')
page_options = page_options.with_indifferent_access
title = page_options['title']
url = page_options['url']
root = page_options['root']
slug = url.nil? ? title.parameterize : url
unless slug[0] == "/" || !!(slug.match(/^https?:\/\/.+/)) || !prefix_url.present?
slug = "#{prefix_url}/#{slug}"
end
if slug == "/" || root == true
slug = ""
end
if slug
slug = slug[1..-1] if slug[0] == "/"
end
slug
end
|