Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix url encoding by multibyte query

- Bugfix url encoding by mutibyte keywords.
  • Loading branch information...
commit 553a339ab0d752a4a52a151e978929e68e7e01bd 1 parent 40b817c
@hirocaster hirocaster authored
Showing with 11 additions and 4 deletions.
  1. +3 −3 lib/google-search/search/base.rb
  2. +8 −1 spec/search_web_spec.rb
View
6 lib/google-search/search/base.rb
@@ -203,10 +203,10 @@ def self.json_decode string
# Url encode _string_.
def self.url_encode string
- string.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
- '%' + $1.unpack('H2' * $1.size).join('%').upcase
+ string.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/) {
+ '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
}.tr(' ', '+')
end
end
-end
+end
View
9 spec/search_web_spec.rb
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/spec_helper'
@@ -38,5 +39,11 @@
@search.get_uri.should include('filter=0')
end
end
+ describe "multibyte string query" do
+ it "url encoding" do
+ @search.query = "日本語"
+ @search.get_uri.should include('%E6%97%A5%E6%9C%AC%E8%AA%9E')
+ end
+ end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.