WXL
3 天以前 9bce51f651aad297ef9eb6df832bfdaf1de05d84
node_modules/webpack/lib/sharing/utils.js
@@ -15,30 +15,30 @@
const RE_URL_GITHUB_EXTREME_SHORT = /^[^/@:.\s][^/@:\s]*\/[^@:\s]*[^/@:\s]#\S+/;
// Short url with specific protocol. eg: github:foo/bar
const RE_GIT_URL_SHORT = /^(github|gitlab|bitbucket|gist):\/?[^/.]+\/?/i;
const RE_GIT_URL_SHORT = /^(?:github|gitlab|bitbucket|gist):\/?[^/.]+\/?/i;
// Currently supported protocols
const RE_PROTOCOL =
   /^((git\+)?(ssh|https?|file)|git|github|gitlab|bitbucket|gist):$/i;
   /^(?:(?:git\+)?(?:ssh|https?|file)|git|github|gitlab|bitbucket|gist):$/i;
// Has custom protocol
const RE_CUSTOM_PROTOCOL = /^((git\+)?(ssh|https?|file)|git):\/\//i;
const RE_CUSTOM_PROTOCOL = /^(?:(?:git\+)?(?:ssh|https?|file)|git):\/\//i;
// Valid hash format for npm / yarn ...
const RE_URL_HASH_VERSION = /#(?:semver:)?(.+)/;
// Simple hostname validate
const RE_HOSTNAME = /^(?:[^/.]+(\.[^/]+)+|localhost)$/;
const RE_HOSTNAME = /^(?:[^/.]+(?:\.[^/]+)+|localhost)$/;
// For hostname with colon. eg: ssh://user@github.com:foo/bar
const RE_HOSTNAME_WITH_COLON =
   /([^/@#:.]+(?:\.[^/@#:.]+)+|localhost):([^#/0-9]+)/;
// Reg for url without protocol
const RE_NO_PROTOCOL = /^([^/@#:.]+(?:\.[^/@#:.]+)+)/;
const RE_NO_PROTOCOL = /^[^/@#:.]+(?:\.[^/@#:.]+)+/;
// RegExp for version string
const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
const VERSION_PATTERN_REGEXP = /^(?:[\d^=v<>~]|[*xX]$)/;
// Specific protocol for short url without normal hostname
const PROTOCOLS_FOR_SHORT = [
@@ -55,6 +55,7 @@
// thanks to https://github.com/npm/hosted-git-info/blob/latest/git-host-info.js
const extractCommithashByDomain = {
   /**
    * Returns hash.
    * @param {string} pathname pathname
    * @param {string} hash hash
    * @returns {string | undefined} hash
@@ -78,6 +79,7 @@
      return commithash;
   },
   /**
    * Returns hash.
    * @param {string} pathname pathname
    * @param {string} hash hash
    * @returns {string | undefined} hash
@@ -102,6 +104,7 @@
      return hash;
   },
   /**
    * Returns hash.
    * @param {string} pathname pathname
    * @param {string} hash hash
    * @returns {string | undefined} hash
@@ -123,6 +126,7 @@
      return hash;
   },
   /**
    * Returns hash.
    * @param {string} pathname pathname
    * @param {string} hash hash
    * @returns {string | undefined} hash
@@ -248,7 +252,9 @@
   gitUrl = correctUrl(gitUrl);
   /** @type {undefined | URL} */
   let parsed;
   try {
      parsed = new URL(gitUrl);
      // eslint-disable-next-line no-empty
@@ -289,6 +295,7 @@
/** @typedef {{ data: JsonObject, path: string }} DescriptionFile */
/**
 * Gets description file.
 * @param {InputFileSystem} fs file system
 * @param {string} directory directory to start looking into
 * @param {string[]} descriptionFiles possible description filenames
@@ -359,6 +366,7 @@
module.exports.getDescriptionFile = getDescriptionFile;
/**
 * Gets required version from description file.
 * @param {JsonObject} data description file data i.e.: package.json
 * @param {string} packageName name of the dependency
 * @returns {string | undefined} normalized version
@@ -379,7 +387,7 @@
         packageName in dependency
      ) {
         return normalizeVersion(
            /** @type {Exclude<JsonPrimitive, null | boolean| number>} */ (
            /** @type {Exclude<JsonPrimitive, null | boolean | number>} */ (
               dependency[packageName]
            )
         );
@@ -391,6 +399,7 @@
   getRequiredVersionFromDescriptionFile;
/**
 * Checks whether this object is required version.
 * @param {string} str maybe required version
 * @returns {boolean} true, if it looks like a version
 */
@@ -401,6 +410,7 @@
module.exports.isRequiredVersion = isRequiredVersion;
/**
 * Normalizes version.
 * @see https://docs.npmjs.com/cli/v7/configuring-npm/package-json#urls-as-dependencies
 * @param {string} versionDesc version to be normalized
 * @returns {string} normalized version