lib/scrivito/cms_routing.rb in scrivito_sdk-0.50.0 vs lib/scrivito/cms_routing.rb in scrivito_sdk-0.50.1

- old
+ new

@@ -16,13 +16,24 @@ end end def convert_links(html) if html - html.gsub(%r{<?\bobjid:([a-f0-9]{16})\b>?}) do + html.gsub(%r{\bobjid:([a-f0-9]{16})\b([^"']*)}) do if obj = Obj.find_by_id($1) - path_or_url(obj, "path") + options = {} + + if $2.present? + begin + uri = URI.parse($2) + options.merge!(extract_query(uri)) + options['anchor'] = uri.fragment + rescue + end + end + + path_or_url(obj, "path", options) else "#__target_object_not_reachable" end end end @@ -109,14 +120,18 @@ end def merge_options(url, options) parsed_url = URI.parse(url) - query = Rack::Utils.parse_query(parsed_url.query) + query = extract_query(parsed_url) merged_query = query.merge(options.stringify_keys) parsed_url.query = merged_query.to_query parsed_url.to_s + end + + def extract_query(uri) + Rack::Utils.parse_query(uri.query) end end end