[Groonga-commit] groonga/gcs [master] Fixup IP address to valid hostname (with xip.io)

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Aug 22 19:03:55 JST 2012


YUKI Hiroshi	2012-08-22 19:03:55 +0900 (Wed, 22 Aug 2012)

  New Revision: 15856fa779b6e12b1fcaa4ac2c05c8b3be8e9fc3
  https://github.com/groonga/gcs/commit/15856fa779b6e12b1fcaa4ac2c05c8b3be8e9fc3

  Log:
    Fixup IP address to valid hostname (with xip.io)

  Modified files:
    lib/database/domain.js

  Modified: lib/database/domain.js (+15 -6)
===================================================================
--- lib/database/domain.js    2012-08-22 17:56:20 +0900 (0a87fa3)
+++ lib/database/domain.js    2012-08-22 19:03:55 +0900 (7278db7)
@@ -49,6 +49,15 @@ function assertValidDomainName(domain) {
   }
 }
 
+function toValidHostAndPort(hostAndPort) {
+  hostAndPort = hostAndPort.split(':');
+  if (hostAndPort[0] == 'localhost')
+    hostAndPort[0] = '127.0.0.1';
+  if (hostAndPort[0].match(/^\d+\.\d+\.\d+\.\d+$/))
+    hostAndPort[0] += '.xip.io';
+  return hostAndPort.join(':');
+}
+
 // Accepts two arguments: source and context.
 // You can give them in the reversed order, like:
 // new Domain("source", context) or new Domain(context, "source")
@@ -251,14 +260,14 @@ Domain.prototype = {
   },
 
   getDocumentsEndpoint: function(hostname) {
-    if (hostname[0] != '.')
-      hostname = '.' + hostname;
-    return 'doc-' + this.name + '-' + this.id + hostname;
+    hostanme = hostname.replace(/^\./, '');
+    hostname = toValidHostAndPort(hostname);
+    return 'doc-' + this.name + '-' + this.id + '.' + hostname;
   },
   getSearchEndpoint: function(hostname) {
-    if (hostname[0] != '.')
-      hostname = '.' + hostname;
-    return 'search-' + this.name + '-' + this.id + hostname;
+    hostanme = hostname.replace(/^\./, '');
+    hostname = toValidHostAndPort(hostname);
+    return 'search-' + this.name + '-' + this.id + '.' + hostname;
   },
 
   createSync: function() {
-------------- next part --------------
HTML����������������������������...
Download 



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