{"size": 2888, "ext": "js", "max_stars_repo_path": "extension/src/json-viewer/url-pattern.js", "max_stars_repo_name": "birobirobiro/json-viewer", "max_stars_repo_stars_event_min_datetime": "2015-01-15T03:12:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:27:42.000Z", "max_issues_repo_path": "extension/src/json-viewer/url-pattern.js", "max_issues_repo_name": "birobirobiro/json-viewer", "max_issues_repo_issues_event_min_datetime": "2015-02-01T06:11:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-10T02:45:49.000Z", "max_forks_repo_path": "extension/src/json-viewer/url-pattern.js", "max_forks_repo_name": "birobirobiro/json-viewer", "max_forks_repo_forks_event_min_datetime": "2015-01-31T19:35:54.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T18:59:05.000Z"}
{"max_stars_count": 2769, "max_issues_count": 262, "max_forks_count": 671, "avg_line_length": 39.027027027, "max_line_length": 89, "alphanum_fraction": 0.6599722992}
// ** With some modifications **
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// the regular expression composed & commented
// could be easily tweaked for RFC compliance,
// it was expressly modified to fit & satisfy
// these test for an URL shortener:
//
//   http://mathiasbynens.be/demo/url-regex
//
// Notes on possible differences from a standard/generic validation:
//
// - utf-8 char class take in consideration the full Unicode range
// - TLDs have been made mandatory so single names like "localhost" fails
// - protocols have been restricted to ftp, http and https only as requested
//
// Changes:
//
// - IP address dotted notation validation, range: 1.0.0.0 - 223.255.255.255
//   first and last IP address of each class is considered invalid
//   (since they are broadcast/network addresses)
//
// - Added exclusion of private, reserved and/or local networks ranges
//
// - Made starting path slash optional (http://example.com?foo=bar)
//
// - Allow a dot (.) at the end of hostnames (http://example.com.)

function relativePath() {
    return "(?:[/?#]\\S*)?";
}

function absolutePath() {
    return "(?:(?:https?|ftp)://)" +        /* protocol identifier*/
        "(?:\\S+(?::\\S*)?@)?" +            /* user:pass authentication*/
        "(?:" +
        "(?:\\[[a-f0-9.:]+\\])" +           /* IPv6 or hybrid addresses*/
        "|" +
        "(?:[a-z0-9\\u00a1-\\uffff.-]+)" +  /* anything else, including IPv4 addresses */
        ")" +
        "(?::\\d{2,5})?" +                  /* port number*/
        relativePath();                     /* resource path*/
}

module.exports = new RegExp("^(" + absolutePath() + "|" + relativePath() + ")$", "i");
