Merge pull request #735 from HyeongBaeYu/huginn_patch

Fix validation issue of Get url maximum length

Andrew Cantino 9 years ago
parent
commit
2a99614919
1 changed files with 9 additions and 3 deletions
  1. 9 3
      app/helpers/dot_helper.rb

+ 9 - 3
app/helpers/dot_helper.rb

@@ -8,9 +8,15 @@ module DotHelper
8 8
         } rescue false)
9 9
       decorate_svg(svg, agents).html_safe
10 10
     else
11
-      tag('img', src: URI('https://chart.googleapis.com/chart').tap { |uri|
12
-            uri.query = URI.encode_www_form(cht: 'gv', chl: agents_dot(agents))
13
-          })
11
+      uriquery = URI.encode_www_form(cht: 'gv', chl: agents_dot(agents))
12
+      #Get query maximum length should be under 2048 bytes with including "chart?" of google chart request url
13
+      if uriquery.length > 2042
14
+        "Too many agent to display, please check unused agents"
15
+      else
16
+        tag('img', src: URI('https://chart.googleapis.com/chart').tap { |uri|
17
+              uri.query = uriquery
18
+	    })
19
+      end
14 20
     end
15 21
   end
16 22