This commit is contained in:
heiye111
2025-09-20 21:06:53 +08:00
commit c74f28caa7
2539 changed files with 365006 additions and 0 deletions

36
node_modules/find-my-way/lib/strategies/accept-host.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
'use strict'
const assert = require('node:assert')
function HostStorage () {
const hosts = new Map()
const regexHosts = []
return {
get: (host) => {
const exact = hosts.get(host)
if (exact) {
return exact
}
for (const regex of regexHosts) {
if (regex.host.test(host)) {
return regex.value
}
}
},
set: (host, value) => {
if (host instanceof RegExp) {
regexHosts.push({ host, value })
} else {
hosts.set(host, value)
}
}
}
}
module.exports = {
name: 'host',
mustMatchWhenDerived: false,
storage: HostStorage,
validate (value) {
assert(typeof value === 'string' || Object.prototype.toString.call(value) === '[object RegExp]', 'Host should be a string or a RegExp')
}
}

View File

@@ -0,0 +1,64 @@
'use strict'
const assert = require('node:assert')
function SemVerStore () {
if (!(this instanceof SemVerStore)) {
return new SemVerStore()
}
this.store = new Map()
this.maxMajor = 0
this.maxMinors = {}
this.maxPatches = {}
}
SemVerStore.prototype.set = function (version, store) {
if (typeof version !== 'string') {
throw new TypeError('Version should be a string')
}
let [major, minor, patch] = version.split('.', 3)
if (isNaN(major)) {
throw new TypeError('Major version must be a numeric value')
}
major = Number(major)
minor = Number(minor) || 0
patch = Number(patch) || 0
if (major >= this.maxMajor) {
this.maxMajor = major
this.store.set('x', store)
this.store.set('*', store)
this.store.set('x.x', store)
this.store.set('x.x.x', store)
}
if (minor >= (this.maxMinors[major] || 0)) {
this.maxMinors[major] = minor
this.store.set(`${major}.x`, store)
this.store.set(`${major}.x.x`, store)
}
if (patch >= (this.maxPatches[`${major}.${minor}`] || 0)) {
this.maxPatches[`${major}.${minor}`] = patch
this.store.set(`${major}.${minor}.x`, store)
}
this.store.set(`${major}.${minor}.${patch}`, store)
return this
}
SemVerStore.prototype.get = function (version) {
return this.store.get(version)
}
module.exports = {
name: 'version',
mustMatchWhenDerived: true,
storage: SemVerStore,
validate (value) {
assert(typeof value === 'string', 'Version should be a string')
}
}

15
node_modules/find-my-way/lib/strategies/http-method.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
'use strict'
module.exports = {
name: '__fmw_internal_strategy_merged_tree_http_method__',
storage: function () {
const handlers = new Map()
return {
get: (type) => { return handlers.get(type) || null },
set: (type, store) => { handlers.set(type, store) }
}
},
/* c8 ignore next 1 */
deriveConstraint: (req) => req.method,
mustMatchWhenDerived: true
}