Module: ThemeBandit::JSParser
Instance Method Summary
collapse
#cdn_to_fqd, #get_absolute_path, #path_with_leading_slash, #strip_query_string
Instance Method Details
#get_js_files ⇒ Object
5
6
7
|
# File 'lib/theme_bandit/parser/js.rb', line 5
def get_js_files
script_tag_values
end
|
#script_tag_values ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/theme_bandit/parser/js.rb', line 15
def script_tag_values
script_tags.map do |tag|
src = tag.attribute('src').to_s
src = cdn_to_fqd(src)
src = URI.parse(src)
if src.absolute?
strip_query_string src.to_s
else
new_src = strip_query_string(src.to_s)
absolute_path = get_absolute_path "#{@url.path}", new_src
absolute = "#{@url.host}#{absolute_path}"
"#{url.scheme}://#{absolute}"
end
end
end
|
9
10
11
12
13
|
# File 'lib/theme_bandit/parser/js.rb', line 9
def script_tags
document.css('script').select do |tag|
tag.attribute('src')
end
end
|