github.com/ccccaoqing/test@v0.0.0-20220510085219-3985d23445c0/misc/chrome/gophertool/gopher.js (about)

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  var numericRE = /^\d+$/;
     6  var commitRE = /^(?:\d+:)?([0-9a-f]{6,20})$/; // e.g "8486:ab29d2698a47" or "ab29d2698a47"
     7  var pkgRE = /^[a-z0-9_\/]+$/;
     8  
     9  function urlForInput(t) {
    10      if (!t) {
    11          return null;
    12      }
    13  
    14      if (numericRE.test(t)) {
    15          if (t < 150000) {
    16              return "http://code.google.com/p/go/issues/detail?id=" + t;
    17          }
    18          return "http://codereview.appspot.com/" + t + "/";
    19      }
    20  
    21      var match = commitRE.exec(t);
    22      if (match) {
    23          return "http://code.google.com/p/go/source/detail?r=" + match[1];
    24      }
    25  
    26      if (pkgRE.test(t)) {
    27          // TODO: make this smarter, using a list of packages + substring matches.
    28          // Get the list from godoc itself in JSON format?
    29          // TODO: prefer localhost:6060 to golang.org if localhost:6060 is responding. 
    30          return "http://golang.org/pkg/" + t;
    31      }
    32  
    33      return null;
    34  }