lib/sinatra/exstatic_assets.rb in sinatra-exstatic-assets-2.0.4 vs lib/sinatra/exstatic_assets.rb in sinatra-exstatic-assets-3.0.0

- old
+ new

@@ -130,21 +130,23 @@ # Wraps around Sinatra::Helpers#uri. Appends a querystring if passed an Asset object. # @param [String,#querystring] addr # @param [Hash] options # @option options [TrueClass] :absolute see Sinatra::Helpers#uri - # @option options [TrueClass] :script_tag Whether to prepend the SCRIPT_TAG env variable. + # @option options [TrueClass] :script_name Whether to prepend the SCRIPT_NAME env variable. # @return [String] # @see Sinatra::Helpers#uri def sss_url_for(addr, options=nil) options ||= {} opts = {timestamp: true}.merge options absolute = opts.delete :absolute absolute = false if absolute.nil? - script_tag = opts.delete(:script_tag) - script_tag = true if script_tag.nil? unless addr.is_uri? - href = uri addr, absolute, script_tag + script_name = + !addr.is_uri? || + opts.delete(:script_name) && addr.start_with?("/") + + href = uri addr, absolute, script_name addr.respond_to?(:querystring) && opts[:timestamp] ? "#{href}#{addr.querystring}" : href end @@ -161,11 +163,11 @@ # Produce a stylesheet link tag. # @param [String] source The file or HTML resource. # @param [Hash] options # @option options [String] :asset_dir The directory the asset is held. Defaults to Sinatra's `public_folder` setting. # @option options [Hash] :url_options Options for devising the URL. - # @option options [TrueClass] :script_tag Whether to prepend the SCRIPT_TAG env variable. + # @option options [TrueClass] :script_name Whether to prepend the SCRIPT_NAME env variable. # @return [Tag] def sss_stylesheet_tag(source, options = {}) asset_dir = options.delete(:asset_dir) || settings.public_folder asset = Asset.new source, asset_dir href = sss_url_for( asset, options.delete(:url_options) ) @@ -274,10 +276,10 @@ alias_method :js_tag, :javascript_tag alias_method :script_tag, :javascript_tag # @param [String] source # @param [Hash] options - # @option options [Hash] :url_options script_tag + # @option options [Hash] :url_options script_name # @example # favicon_tag # # => <link href="/favicon.ico" rel="icon"> def favicon_tag(*args) source, options = sss_extract_options args