[Groonga-commit] droonga/droonga-engine at ecabd8a [master] Don't use custom parser for routing path

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Apr 30 15:45:00 JST 2015


YUKI Hiroshi	2015-04-30 15:45:00 +0900 (Thu, 30 Apr 2015)

  New Revision: ecabd8a7bcfc20538b4d78a14db4db8bf463a27c
  https://github.com/droonga/droonga-engine/commit/ecabd8a7bcfc20538b4d78a14db4db8bf463a27c

  Message:
    Don't use custom parser for routing path

  Modified files:
    lib/droonga/engine_state.rb

  Modified: lib/droonga/engine_state.rb (+25 -28)
===================================================================
--- lib/droonga/engine_state.rb    2015-04-30 15:43:33 +0900 (fbc0789)
+++ lib/droonga/engine_state.rb    2015-04-30 15:45:00 +0900 (9a2d4aa)
@@ -17,6 +17,7 @@ require "English"
 
 require "droonga/loggable"
 require "droonga/deferrable"
+require "droonga/address"
 require "droonga/event_loop"
 require "droonga/forwarder"
 require "droonga/replier"
@@ -66,52 +67,48 @@ module Droonga
       route.start_with?(@name) or route.start_with?(@internal_name)
     end
 
-    FARM_PATH_MATCHER = /\A[^:]+:\d+\/[^.]+/
-
     def internal_route(route)
-      if FARM_PATH_MATCHER =~ route
-        name = $MATCH
-        if name == @name or name == @internal_name
-          return route.sub(name, @internal_name)
-        end
+      name = Address.parse(route).node
+      if name == @name
+        route.sub(name, @internal_name)
+      else
+        route
       end
+    rescue ArgumentError
       route
     end
 
     def public_route(route)
-      if FARM_PATH_MATCHER =~ route
-        name = $MATCH
-        if name == @internal_name
-          return route.sub(name, @name)
-        end
+      name = Address.parse(route).node
+      if name == @internal_name
+        route.sub(name, @name)
+      else
+        route
       end
+    rescue ArgumentError
       route
     end
 
     def internal_farm_path(route)
-      if FARM_PATH_MATCHER =~ route
-        name = $MATCH
-        if name == @name or name == @internal_name
-          @internal_name
-        else
-          name
-        end
+      name = Address.parse(route).node
+      if name == @name
+        @internal_name
       else
-        route
+        name
       end
+    rescue ArgumentError
+      route
     end
 
     def public_farm_path(route)
-      if FARM_PATH_MATCHER =~ route
-        name = $MATCH
-        if name == @internal_name
-          @name
-        else
-          name
-        end
+      name = Address.parse(route).node
+      if name == @internal_name
+        @name
       else
-        route
+        name
       end
+    rescue ArgumentError
+      route
     end
 
     def generate_id
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index