lib/onebox/engine/google_maps_onebox.rb in onebox-1.5.21 vs lib/onebox/engine/google_maps_onebox.rb in onebox-1.5.22

- old
+ new

@@ -17,10 +17,12 @@ def matches_regexp(key, regexp) (@@matchers ||= []) << {key: key, regexp: regexp} end end + always_https + # Matches shortened Google Maps URLs matches_regexp :short, %r"^(https?:)?//goo\.gl/maps/" # Matches URLs for custom-created maps matches_regexp :custom, %r"^(?:https?:)?//www\.google(?:\.(?:\w{2,}))+/maps/d/(?:edit|viewer|embed)\?mid=.+$" @@ -93,11 +95,11 @@ location = "#{match[:lon]},#{match[:lat]}" url = "https://maps.google.com/maps?ll=#{location}&z=#{zoom}&output=embed&dg=ntvb" url += "&q=#{$1}" if match = @url.match(/\/place\/([^\/\?]+)/) url += "&cid=#{($1 + $2).to_i(16)}" if @url.match(/!3m1!1s0x(\h{16}):0x(\h{16})/) @url = url - @placeholder = "http://maps.googleapis.com/maps/api/staticmap?maptype=roadmap&center=#{location}&zoom=#{zoom}&size=690x400&sensor=false" + @placeholder = "https://maps.googleapis.com/maps/api/staticmap?maptype=roadmap&center=#{location}&zoom=#{zoom}&size=690x400&sensor=false" when :custom url = @url.dup @url = rewrite_custom_url(url, "embed") @placeholder = rewrite_custom_url(url, "thumbnail") @@ -111,11 +113,11 @@ heading = match[:heading].to_f.round(4).to_s pitch = (match[:pitch].to_f / 10.0).round(4).to_s fov = (match[:zoom].to_f / 100.0).round(4).to_s zoom = match[:zoom].to_f.round @url = "https://www.google.com/maps/embed?pb=!3m2!2sen!4v0!6m8!1m7!1s#{panoid}!2m2!1d#{lon}!2d#{lat}!3f#{heading}!4f#{pitch}!5f#{fov}" - @placeholder = "http://maps.googleapis.com/maps/api/streetview?size=690x400&location=#{lon},#{lat}&pano=#{panoid}&fov=#{zoom}&heading=#{heading}&pitch=#{pitch}&sensor=false" + @placeholder = "https://maps.googleapis.com/maps/api/streetview?size=690x400&location=#{lon},#{lat}&pano=#{panoid}&fov=#{zoom}&heading=#{heading}&pitch=#{pitch}&sensor=false" when :canonical uri = URI(@url) query = Hash[*uri.query.split("&").map{|a|a.split("=")}.flatten] if !query.has_key?("ll") @@ -134,10 +136,10 @@ zoom = (Math.log(690.0 * 360.0 / angle / 256.0) / Math.log(2)).round else zoom = query["z"] end @url = @url.sub('output=classic', 'output=embed') - @placeholder = "http://maps.googleapis.com/maps/api/staticmap?maptype=roadmap&size=690x400&sensor=false&center=#{location}&zoom=#{zoom}" + @placeholder = "https://maps.googleapis.com/maps/api/staticmap?maptype=roadmap&size=690x400&sensor=false&center=#{location}&zoom=#{zoom}" else raise "unexpected url type #{type.inspect}" end end