lib/hanami/assets/helpers.rb in hanami-assets-1.1.0.rc1 vs lib/hanami/assets/helpers.rb in hanami-assets-1.1.0
- old
+ new
@@ -60,10 +60,14 @@
# @since 0.3.0
# @api private
ABSOLUTE_URL_MATCHER = URI::DEFAULT_PARSER.make_regexp
+ # @since 1.1.0
+ # @api private
+ QUERY_STRING_MATCHER = /\?/
+
include Hanami::Helpers::HtmlHelper
# Inject helpers into the given class
#
# @since 0.1.0
@@ -756,11 +760,11 @@
end
# @since 0.1.0
# @api private
def _typed_asset_path(source, ext)
- source = "#{source}#{ext}" unless source =~ /#{Regexp.escape(ext)}\z/
+ source = "#{source}#{ext}" if _append_extension?(source, ext)
asset_path(source)
end
# @api private
def _subresource_integrity?
@@ -816,9 +820,15 @@
Thread.current[:__hanami_assets] ||= Set.new
Thread.current[:__hanami_assets].add(url.to_s)
end
url
+ end
+
+ # @since 1.1.0
+ # @api private
+ def _append_extension?(source, ext)
+ source !~ QUERY_STRING_MATCHER && source !~ /#{Regexp.escape(ext)}\z/
end
end
end
end