lib/write_xlsx/worksheet/hyperlink.rb in write_xlsx-0.89.0 vs lib/write_xlsx/worksheet/hyperlink.rb in write_xlsx-0.90.0

- old
+ new

@@ -25,17 +25,11 @@ # Strip the mailto header. normalized_str = str.sub(/^mailto:/, '') # Split url into the link and optional anchor/location. - url, *anchors = url.split(/#/) - url ||= '' - if anchors.empty? - @url_str = nil - else - @url_str = anchors.join('#') - end + url, @url_str = url.split(/#/, 2) # Escape URL unless it looks already escaped. url = escape_url(url) # Excel limits the escaped URL and location/anchor to 255 characters. @@ -133,17 +127,14 @@ str.gsub!(%r|/|, '\\') # Strip the mailto header. str.sub!(/^mailto:/, '') + # Split url into the link and optional anchor/location. + url, url_str = url.split(/#/, 2) + # Escape URL unless it looks already escaped. url = escape_url(url) - - # External Workbook links need to be modified into the right format. - # The URL will look something like 'c:\temp\file.xlsx#Sheet!A1'. - # We need the part to the left of the # as the URL and the part to - # the right as the "location" string (if it exists). - url, url_str = url.split(/#/) # Add the file:/// URI to the url if non-local. if url =~ %r![:]! || # Windows style "C:/" link. url =~ %r!^\\\\! # Network share. url = "file:///#{url}"