mirror of
https://github.com/DavidAnson/markdownlint-cli2-action.git
synced 2026-06-30 23:19:41 +02:00
Freshen generated index.js file.
This commit is contained in:
Vendored
+291
-150
@@ -14826,7 +14826,6 @@ function defaultFactory (origin, opts) {
|
||||
|
||||
class Agent extends DispatcherBase {
|
||||
constructor ({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) {
|
||||
|
||||
if (typeof factory !== 'function') {
|
||||
throw new InvalidArgumentError('factory must be a function.')
|
||||
}
|
||||
@@ -15212,6 +15211,9 @@ const EMPTY_BUF = Buffer.alloc(0)
|
||||
const FastBuffer = Buffer[Symbol.species]
|
||||
const addListener = util.addListener
|
||||
const removeAllListeners = util.removeAllListeners
|
||||
const kIdleSocketValidation = Symbol('kIdleSocketValidation')
|
||||
const kIdleSocketValidationTimeout = Symbol('kIdleSocketValidationTimeout')
|
||||
const kSocketUsed = Symbol('kSocketUsed')
|
||||
|
||||
let extractBody
|
||||
|
||||
@@ -15434,29 +15436,71 @@ class Parser {
|
||||
|
||||
const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr
|
||||
|
||||
if (ret === constants.ERROR.PAUSED_UPGRADE) {
|
||||
this.onUpgrade(data.slice(offset))
|
||||
} else if (ret === constants.ERROR.PAUSED) {
|
||||
this.paused = true
|
||||
socket.unshift(data.slice(offset))
|
||||
} else if (ret !== constants.ERROR.OK) {
|
||||
const ptr = llhttp.llhttp_get_error_reason(this.ptr)
|
||||
let message = ''
|
||||
/* istanbul ignore else: difficult to make a test case for */
|
||||
if (ptr) {
|
||||
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
|
||||
message =
|
||||
'Response does not match the HTTP/1.1 protocol (' +
|
||||
Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
|
||||
')'
|
||||
if (ret !== constants.ERROR.OK) {
|
||||
const body = data.subarray(offset)
|
||||
|
||||
if (ret === constants.ERROR.PAUSED_UPGRADE) {
|
||||
this.onUpgrade(body)
|
||||
} else if (ret === constants.ERROR.PAUSED) {
|
||||
this.paused = true
|
||||
socket.unshift(body)
|
||||
} else {
|
||||
throw this.createError(ret, body)
|
||||
}
|
||||
throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset))
|
||||
}
|
||||
} catch (err) {
|
||||
util.destroy(socket, err)
|
||||
}
|
||||
}
|
||||
|
||||
finish () {
|
||||
assert(currentParser === null)
|
||||
assert(this.ptr != null)
|
||||
assert(!this.paused)
|
||||
|
||||
const { llhttp } = this
|
||||
|
||||
let ret
|
||||
|
||||
try {
|
||||
currentParser = this
|
||||
ret = llhttp.llhttp_finish(this.ptr)
|
||||
} finally {
|
||||
currentParser = null
|
||||
}
|
||||
|
||||
if (ret === constants.ERROR.OK) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
|
||||
this.paused = true
|
||||
return null
|
||||
}
|
||||
|
||||
return this.createError(ret, EMPTY_BUF)
|
||||
}
|
||||
|
||||
createError (ret, data) {
|
||||
const { llhttp, contentLength, bytesRead } = this
|
||||
|
||||
if (contentLength && bytesRead !== parseInt(contentLength, 10)) {
|
||||
return new ResponseContentLengthMismatchError()
|
||||
}
|
||||
|
||||
const ptr = llhttp.llhttp_get_error_reason(this.ptr)
|
||||
let message = ''
|
||||
if (ptr) {
|
||||
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
|
||||
message =
|
||||
'Response does not match the HTTP/1.1 protocol (' +
|
||||
Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
|
||||
')'
|
||||
}
|
||||
|
||||
return new HTTPParserError(message, constants.ERROR[ret], data)
|
||||
}
|
||||
|
||||
destroy () {
|
||||
assert(this.ptr != null)
|
||||
assert(currentParser == null)
|
||||
@@ -15484,6 +15528,11 @@ class Parser {
|
||||
return -1
|
||||
}
|
||||
|
||||
if (client[kRunning] === 0) {
|
||||
util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
|
||||
return -1
|
||||
}
|
||||
|
||||
const request = client[kQueue][client[kRunningIdx]]
|
||||
if (!request) {
|
||||
return -1
|
||||
@@ -15587,6 +15636,11 @@ class Parser {
|
||||
return -1
|
||||
}
|
||||
|
||||
if (client[kRunning] === 0) {
|
||||
util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
|
||||
return -1
|
||||
}
|
||||
|
||||
const request = client[kQueue][client[kRunningIdx]]
|
||||
|
||||
/* istanbul ignore next: difficult to make a test case for */
|
||||
@@ -15760,6 +15814,7 @@ class Parser {
|
||||
request.onComplete(headers)
|
||||
|
||||
client[kQueue][client[kRunningIdx]++] = null
|
||||
socket[kSocketUsed] = true
|
||||
|
||||
if (socket[kWriting]) {
|
||||
assert(client[kRunning] === 0)
|
||||
@@ -15818,6 +15873,9 @@ async function connectH1 (client, socket) {
|
||||
socket[kWriting] = false
|
||||
socket[kReset] = false
|
||||
socket[kBlocking] = false
|
||||
socket[kIdleSocketValidation] = 0
|
||||
socket[kIdleSocketValidationTimeout] = null
|
||||
socket[kSocketUsed] = false
|
||||
socket[kParser] = new Parser(client, socket, llhttpInstance)
|
||||
|
||||
addListener(socket, 'error', function (err) {
|
||||
@@ -15828,8 +15886,11 @@ async function connectH1 (client, socket) {
|
||||
// On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
|
||||
// to the user.
|
||||
if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
|
||||
// We treat all incoming data so for as a valid response.
|
||||
parser.onMessageComplete()
|
||||
const parserErr = parser.finish()
|
||||
if (parserErr) {
|
||||
this[kError] = parserErr
|
||||
this[kClient][kOnError](parserErr)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -15848,8 +15909,10 @@ async function connectH1 (client, socket) {
|
||||
const parser = this[kParser]
|
||||
|
||||
if (parser.statusCode && !parser.shouldKeepAlive) {
|
||||
// We treat all incoming data so far as a valid response.
|
||||
parser.onMessageComplete()
|
||||
const parserErr = parser.finish()
|
||||
if (parserErr) {
|
||||
util.destroy(this, parserErr)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -15859,10 +15922,11 @@ async function connectH1 (client, socket) {
|
||||
const client = this[kClient]
|
||||
const parser = this[kParser]
|
||||
|
||||
clearIdleSocketValidation(this)
|
||||
|
||||
if (parser) {
|
||||
if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
|
||||
// We treat all incoming data so far as a valid response.
|
||||
parser.onMessageComplete()
|
||||
this[kError] = parser.finish() || this[kError]
|
||||
}
|
||||
|
||||
this[kParser].destroy()
|
||||
@@ -15925,7 +15989,7 @@ async function connectH1 (client, socket) {
|
||||
return socket.destroyed
|
||||
},
|
||||
busy (request) {
|
||||
if (socket[kWriting] || socket[kReset] || socket[kBlocking]) {
|
||||
if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -15963,6 +16027,31 @@ async function connectH1 (client, socket) {
|
||||
}
|
||||
}
|
||||
|
||||
function clearIdleSocketValidation (socket) {
|
||||
if (socket[kIdleSocketValidationTimeout]) {
|
||||
clearTimeout(socket[kIdleSocketValidationTimeout])
|
||||
socket[kIdleSocketValidationTimeout] = null
|
||||
}
|
||||
|
||||
socket[kIdleSocketValidation] = 0
|
||||
}
|
||||
|
||||
function scheduleIdleSocketValidation (client, socket) {
|
||||
socket[kIdleSocketValidation] = 1
|
||||
socket[kIdleSocketValidationTimeout] = setTimeout(() => {
|
||||
socket[kIdleSocketValidationTimeout] = null
|
||||
socket[kIdleSocketValidation] = 2
|
||||
|
||||
if (client[kSocket] === socket && !socket.destroyed) {
|
||||
client[kResume]()
|
||||
}
|
||||
}, 0)
|
||||
socket[kIdleSocketValidationTimeout].unref?.()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./client.js')} client
|
||||
*/
|
||||
function resumeH1 (client) {
|
||||
const socket = client[kSocket]
|
||||
|
||||
@@ -15977,6 +16066,32 @@ function resumeH1 (client) {
|
||||
socket[kNoRef] = false
|
||||
}
|
||||
|
||||
if (client[kRunning] === 0 && client[kPending] > 0 && socket[kSocketUsed]) {
|
||||
if (socket[kIdleSocketValidation] === 0) {
|
||||
scheduleIdleSocketValidation(client, socket)
|
||||
socket[kParser].readMore()
|
||||
if (socket.destroyed) {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (socket[kIdleSocketValidation] === 1) {
|
||||
socket[kParser].readMore()
|
||||
if (socket.destroyed) {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (client[kRunning] === 0) {
|
||||
socket[kParser].readMore()
|
||||
if (socket.destroyed) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (client[kSize] === 0) {
|
||||
if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) {
|
||||
socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE)
|
||||
@@ -16070,6 +16185,7 @@ function writeH1 (client, request) {
|
||||
}
|
||||
|
||||
const socket = client[kSocket]
|
||||
clearIdleSocketValidation(socket)
|
||||
|
||||
const abort = (err) => {
|
||||
if (request.aborted || request.completed) {
|
||||
@@ -17939,6 +18055,7 @@ class DispatcherBase extends Dispatcher {
|
||||
|
||||
get webSocketOptions () {
|
||||
return {
|
||||
maxFragments: this[kWebSocketOptions].maxFragments ?? 131072,
|
||||
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
|
||||
}
|
||||
}
|
||||
@@ -23838,32 +23955,25 @@ function parseUnparsedAttributes (unparsedAttributes, cookieAttributeList = {})
|
||||
// If the attribute-name case-insensitively matches the string
|
||||
// "SameSite", the user agent MUST process the cookie-av as follows:
|
||||
|
||||
// 1. Let enforcement be "Default".
|
||||
let enforcement = 'Default'
|
||||
|
||||
const attributeValueLowercase = attributeValue.toLowerCase()
|
||||
// 2. If cookie-av's attribute-value is a case-insensitive match for
|
||||
// "None", set enforcement to "None".
|
||||
if (attributeValueLowercase.includes('none')) {
|
||||
enforcement = 'None'
|
||||
}
|
||||
|
||||
// 3. If cookie-av's attribute-value is a case-insensitive match for
|
||||
// "Strict", set enforcement to "Strict".
|
||||
if (attributeValueLowercase.includes('strict')) {
|
||||
enforcement = 'Strict'
|
||||
// 1. If cookie-av's attribute-value is a case-insensitive match for
|
||||
// "None", append an attribute to the cookie-attribute-list with an
|
||||
// attribute-name of "SameSite" and an attribute-value of "None".
|
||||
if (attributeValueLowercase === 'none') {
|
||||
cookieAttributeList.sameSite = 'None'
|
||||
} else if (attributeValueLowercase === 'strict') {
|
||||
// 2. If cookie-av's attribute-value is a case-insensitive match for
|
||||
// "Strict", append an attribute to the cookie-attribute-list with
|
||||
// an attribute-name of "SameSite" and an attribute-value of
|
||||
// "Strict".
|
||||
cookieAttributeList.sameSite = 'Strict'
|
||||
} else if (attributeValueLowercase === 'lax') {
|
||||
// 3. If cookie-av's attribute-value is a case-insensitive match for
|
||||
// "Lax", append an attribute to the cookie-attribute-list with an
|
||||
// attribute-name of "SameSite" and an attribute-value of "Lax".
|
||||
cookieAttributeList.sameSite = 'Lax'
|
||||
}
|
||||
|
||||
// 4. If cookie-av's attribute-value is a case-insensitive match for
|
||||
// "Lax", set enforcement to "Lax".
|
||||
if (attributeValueLowercase.includes('lax')) {
|
||||
enforcement = 'Lax'
|
||||
}
|
||||
|
||||
// 5. Append an attribute to the cookie-attribute-list with an
|
||||
// attribute-name of "SameSite" and an attribute-value of
|
||||
// enforcement.
|
||||
cookieAttributeList.sameSite = enforcement
|
||||
} else {
|
||||
cookieAttributeList.unparsed ??= []
|
||||
|
||||
@@ -36659,6 +36769,11 @@ const { closeWebSocketConnection } = __nccwpck_require__(6897)
|
||||
const { PerMessageDeflate } = __nccwpck_require__(9469)
|
||||
const { MessageSizeExceededError } = __nccwpck_require__(8707)
|
||||
|
||||
function failWebsocketConnectionWithCode (ws, code, reason) {
|
||||
closeWebSocketConnection(ws, code, reason, Buffer.byteLength(reason))
|
||||
failWebsocketConnection(ws, reason)
|
||||
}
|
||||
|
||||
// This code was influenced by ws released under the MIT license.
|
||||
// Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
||||
// Copyright (c) 2013 Arnout Kazemier and contributors
|
||||
@@ -36678,19 +36793,23 @@ class ByteParser extends Writable {
|
||||
/** @type {Map<string, PerMessageDeflate>} */
|
||||
#extensions
|
||||
|
||||
/** @type {number} */
|
||||
#maxFragments
|
||||
|
||||
/** @type {number} */
|
||||
#maxPayloadSize
|
||||
|
||||
/**
|
||||
* @param {import('./websocket').WebSocket} ws
|
||||
* @param {Map<string, string>|null} extensions
|
||||
* @param {{ maxPayloadSize?: number }} [options]
|
||||
* @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
|
||||
*/
|
||||
constructor (ws, extensions, options = {}) {
|
||||
super()
|
||||
|
||||
this.ws = ws
|
||||
this.#extensions = extensions == null ? new Map() : extensions
|
||||
this.#maxFragments = options.maxFragments ?? 0
|
||||
this.#maxPayloadSize = options.maxPayloadSize ?? 0
|
||||
|
||||
if (this.#extensions.has('permessage-deflate')) {
|
||||
@@ -36714,9 +36833,9 @@ class ByteParser extends Writable {
|
||||
if (
|
||||
this.#maxPayloadSize > 0 &&
|
||||
!isControlFrame(this.#info.opcode) &&
|
||||
this.#info.payloadLength > this.#maxPayloadSize
|
||||
this.#info.payloadLength + this.#fragmentsBytes > this.#maxPayloadSize
|
||||
) {
|
||||
failWebsocketConnection(this.ws, 'Payload size exceeds maximum allowed size')
|
||||
failWebsocketConnectionWithCode(this.ws, 1009, 'Payload size exceeds maximum allowed size')
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -36881,10 +37000,12 @@ class ByteParser extends Writable {
|
||||
this.#state = parserStates.INFO
|
||||
} else {
|
||||
if (!this.#info.compressed) {
|
||||
this.writeFragments(body)
|
||||
if (!this.writeFragments(body)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
||||
failWebsocketConnection(this.ws, new MessageSizeExceededError().message)
|
||||
failWebsocketConnectionWithCode(this.ws, 1009, new MessageSizeExceededError().message)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -36903,14 +37024,17 @@ class ByteParser extends Writable {
|
||||
this.#info.fin,
|
||||
(error, data) => {
|
||||
if (error) {
|
||||
failWebsocketConnection(this.ws, error.message)
|
||||
const code = error instanceof MessageSizeExceededError ? 1009 : 1007
|
||||
failWebsocketConnectionWithCode(this.ws, code, error.message)
|
||||
return
|
||||
}
|
||||
|
||||
this.writeFragments(data)
|
||||
if (!this.writeFragments(data)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
|
||||
failWebsocketConnection(this.ws, new MessageSizeExceededError().message)
|
||||
failWebsocketConnectionWithCode(this.ws, 1009, new MessageSizeExceededError().message)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -36980,8 +37104,17 @@ class ByteParser extends Writable {
|
||||
}
|
||||
|
||||
writeFragments (fragment) {
|
||||
if (
|
||||
this.#maxFragments > 0 &&
|
||||
this.#fragments.length === this.#maxFragments
|
||||
) {
|
||||
failWebsocketConnectionWithCode(this.ws, 1008, 'Too many message fragments')
|
||||
return false
|
||||
}
|
||||
|
||||
this.#fragmentsBytes += fragment.length
|
||||
this.#fragments.push(fragment)
|
||||
return true
|
||||
}
|
||||
|
||||
consumeFragments () {
|
||||
@@ -38030,9 +38163,12 @@ class WebSocket extends EventTarget {
|
||||
// once this happens, the connection is open
|
||||
this[kResponse] = response
|
||||
|
||||
const maxPayloadSize = this[kController]?.dispatcher?.webSocketOptions?.maxPayloadSize
|
||||
const webSocketOptions = this[kController]?.dispatcher?.webSocketOptions
|
||||
const maxFragments = webSocketOptions?.maxFragments
|
||||
const maxPayloadSize = webSocketOptions?.maxPayloadSize
|
||||
|
||||
const parser = new ByteParser(this, parsedExtensions, {
|
||||
maxFragments,
|
||||
maxPayloadSize
|
||||
})
|
||||
parser.on('drain', onParserDrain)
|
||||
@@ -47306,11 +47442,6 @@ const tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghik
|
||||
// DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
|
||||
const tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|')
|
||||
|
||||
function resetScanCache (self) {
|
||||
self.__index__ = -1
|
||||
self.__text_cache__ = ''
|
||||
}
|
||||
|
||||
function createValidator (re) {
|
||||
return function (text, pos) {
|
||||
const tail = text.slice(pos)
|
||||
@@ -47349,8 +47480,11 @@ function compile (self) {
|
||||
function untpl (tpl) { return tpl.replace('%TLDS%', re.src_tlds) }
|
||||
|
||||
re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i')
|
||||
re.email_fuzzy_global = RegExp(untpl(re.tpl_email_fuzzy), 'ig')
|
||||
re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i')
|
||||
re.link_fuzzy_global = RegExp(untpl(re.tpl_link_fuzzy), 'ig')
|
||||
re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i')
|
||||
re.link_no_ip_fuzzy_global = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'ig')
|
||||
re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i')
|
||||
|
||||
//
|
||||
@@ -47444,12 +47578,6 @@ function compile (self) {
|
||||
'(' + self.re.schema_test.source + ')|(' + self.re.host_fuzzy_test.source + ')|@',
|
||||
'i'
|
||||
)
|
||||
|
||||
//
|
||||
// Cleanup
|
||||
//
|
||||
|
||||
resetScanCache(self)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47457,55 +47585,45 @@ function compile (self) {
|
||||
*
|
||||
* Match result. Single element of array, returned by [[LinkifyIt#match]]
|
||||
**/
|
||||
function Match (self, shift) {
|
||||
const start = self.__index__
|
||||
const end = self.__last_index__
|
||||
const text = self.__text_cache__.slice(start, end)
|
||||
function Match (text, schema, index, lastIndex) {
|
||||
const raw = text.slice(index, lastIndex)
|
||||
|
||||
/**
|
||||
* Match#schema -> String
|
||||
*
|
||||
* Prefix (protocol) for matched string.
|
||||
**/
|
||||
this.schema = self.__schema__.toLowerCase()
|
||||
this.schema = schema.toLowerCase()
|
||||
/**
|
||||
* Match#index -> Number
|
||||
*
|
||||
* First position of matched string.
|
||||
**/
|
||||
this.index = start + shift
|
||||
this.index = index
|
||||
/**
|
||||
* Match#lastIndex -> Number
|
||||
*
|
||||
* Next position after matched string.
|
||||
**/
|
||||
this.lastIndex = end + shift
|
||||
this.lastIndex = lastIndex
|
||||
/**
|
||||
* Match#raw -> String
|
||||
*
|
||||
* Matched string.
|
||||
**/
|
||||
this.raw = text
|
||||
this.raw = raw
|
||||
/**
|
||||
* Match#text -> String
|
||||
*
|
||||
* Notmalized text of matched string.
|
||||
**/
|
||||
this.text = text
|
||||
this.text = raw
|
||||
/**
|
||||
* Match#url -> String
|
||||
*
|
||||
* Normalized url of matched string.
|
||||
**/
|
||||
this.url = text
|
||||
}
|
||||
|
||||
function createMatch (self, shift) {
|
||||
const match = new Match(self, shift)
|
||||
|
||||
self.__compiled__[match.schema].normalize(match, self)
|
||||
|
||||
return match
|
||||
this.url = raw
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47560,12 +47678,6 @@ function LinkifyIt (schemas, options) {
|
||||
|
||||
this.__opts__ = linkify_it_assign({}, defaultOptions, options)
|
||||
|
||||
// Cache last tested result. Used to skip repeating steps on next `match` call.
|
||||
this.__index__ = -1
|
||||
this.__last_index__ = -1 // Next scan position
|
||||
this.__schema__ = ''
|
||||
this.__text_cache__ = ''
|
||||
|
||||
this.__schemas__ = linkify_it_assign({}, defaultSchemas, schemas)
|
||||
this.__compiled__ = {}
|
||||
|
||||
@@ -47607,69 +47719,38 @@ LinkifyIt.prototype.set = function set (options) {
|
||||
* Searches linkifiable pattern and returns `true` on success or `false` on fail.
|
||||
**/
|
||||
LinkifyIt.prototype.test = function test (text) {
|
||||
// Reset scan cache
|
||||
this.__text_cache__ = text
|
||||
this.__index__ = -1
|
||||
|
||||
if (!text.length) { return false }
|
||||
|
||||
let m, ml, me, len, shift, next, re, tld_pos, at_pos
|
||||
let m, re
|
||||
|
||||
// try to scan for link with schema - that's the most simple rule
|
||||
if (this.re.schema_test.test(text)) {
|
||||
re = this.re.schema_search
|
||||
re.lastIndex = 0
|
||||
while ((m = re.exec(text)) !== null) {
|
||||
len = this.testSchemaAt(text, m[2], re.lastIndex)
|
||||
if (len) {
|
||||
this.__schema__ = m[2]
|
||||
this.__index__ = m.index + m[1].length
|
||||
this.__last_index__ = m.index + m[0].length + len
|
||||
break
|
||||
}
|
||||
if (this.testSchemaAt(text, m[2], re.lastIndex)) { return true }
|
||||
}
|
||||
}
|
||||
|
||||
if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
|
||||
// guess schemaless links
|
||||
tld_pos = text.search(this.re.host_fuzzy_test)
|
||||
if (tld_pos >= 0) {
|
||||
// if tld is located after found link - no need to check fuzzy pattern
|
||||
if (this.__index__ < 0 || tld_pos < this.__index__) {
|
||||
if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
|
||||
shift = ml.index + ml[1].length
|
||||
|
||||
if (this.__index__ < 0 || shift < this.__index__) {
|
||||
this.__schema__ = ''
|
||||
this.__index__ = shift
|
||||
this.__last_index__ = ml.index + ml[0].length
|
||||
}
|
||||
}
|
||||
if (text.search(this.re.host_fuzzy_test) >= 0) {
|
||||
if (text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy) !== null) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
|
||||
// guess schemaless emails
|
||||
at_pos = text.indexOf('@')
|
||||
if (at_pos >= 0) {
|
||||
if (text.indexOf('@') >= 0) {
|
||||
// We can't skip this check, because this cases are possible:
|
||||
// 192.168.1.1@gmail.com, my.in@example.com
|
||||
if ((me = text.match(this.re.email_fuzzy)) !== null) {
|
||||
shift = me.index + me[1].length
|
||||
next = me.index + me[0].length
|
||||
|
||||
if (this.__index__ < 0 || shift < this.__index__ ||
|
||||
(shift === this.__index__ && next > this.__last_index__)) {
|
||||
this.__schema__ = 'mailto:'
|
||||
this.__index__ = shift
|
||||
this.__last_index__ = next
|
||||
}
|
||||
}
|
||||
if (text.match(this.re.email_fuzzy) !== null) { return true }
|
||||
}
|
||||
}
|
||||
|
||||
return this.__index__ >= 0
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47718,23 +47799,88 @@ LinkifyIt.prototype.testSchemaAt = function testSchemaAt (text, schema, pos) {
|
||||
**/
|
||||
LinkifyIt.prototype.match = function match (text) {
|
||||
const result = []
|
||||
let shift = 0
|
||||
const type_schemed = []
|
||||
const type_fuzzy_link = []
|
||||
const type_fuzzy_email = []
|
||||
let m, len, re
|
||||
|
||||
// Try to take previous element from cache, if .test() called before
|
||||
if (this.__index__ >= 0 && this.__text_cache__ === text) {
|
||||
result.push(createMatch(this, shift))
|
||||
shift = this.__last_index__
|
||||
function choose (a, b) {
|
||||
if (!a) { return b }
|
||||
if (!b) { return a }
|
||||
if (a.index !== b.index) { return a.index < b.index ? a : b }
|
||||
return a.lastIndex >= b.lastIndex ? a : b
|
||||
}
|
||||
|
||||
// Cut head if cache was used
|
||||
let tail = shift ? text.slice(shift) : text
|
||||
if (!text.length) { return null }
|
||||
|
||||
// Scan string until end reached
|
||||
while (this.test(tail)) {
|
||||
result.push(createMatch(this, shift))
|
||||
// scan for links with schema
|
||||
if (this.re.schema_test.test(text)) {
|
||||
re = this.re.schema_search
|
||||
re.lastIndex = 0
|
||||
while ((m = re.exec(text)) !== null) {
|
||||
len = this.testSchemaAt(text, m[2], re.lastIndex)
|
||||
if (len) {
|
||||
type_schemed.push({
|
||||
schema: m[2],
|
||||
index: m.index + m[1].length,
|
||||
lastIndex: m.index + m[0].length + len
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tail = tail.slice(this.__last_index__)
|
||||
shift += this.__last_index__
|
||||
if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
|
||||
re = this.__opts__.fuzzyIP ? this.re.link_fuzzy_global : this.re.link_no_ip_fuzzy_global
|
||||
re.lastIndex = 0
|
||||
while ((m = re.exec(text)) !== null) {
|
||||
type_fuzzy_link.push({
|
||||
schema: '',
|
||||
index: m.index + m[1].length,
|
||||
lastIndex: m.index + m[0].length
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
|
||||
re = this.re.email_fuzzy_global
|
||||
re.lastIndex = 0
|
||||
while ((m = re.exec(text)) !== null) {
|
||||
type_fuzzy_email.push({
|
||||
schema: 'mailto:',
|
||||
index: m.index + m[1].length,
|
||||
lastIndex: m.index + m[0].length
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const indexes = [0, 0, 0]
|
||||
let lastIndex = 0
|
||||
|
||||
for (;;) {
|
||||
const candidates = [
|
||||
type_schemed[indexes[0]],
|
||||
type_fuzzy_email[indexes[1]],
|
||||
type_fuzzy_link[indexes[2]]
|
||||
]
|
||||
|
||||
const candidate = choose(choose(candidates[0], candidates[1]), candidates[2])
|
||||
|
||||
if (!candidate) { break }
|
||||
|
||||
if (candidate === candidates[0]) {
|
||||
indexes[0]++
|
||||
} else if (candidate === candidates[1]) {
|
||||
indexes[1]++
|
||||
} else {
|
||||
indexes[2]++
|
||||
}
|
||||
|
||||
if (candidate.index < lastIndex) { continue }
|
||||
|
||||
const match = new Match(text, candidate.schema, candidate.index, candidate.lastIndex)
|
||||
this.__compiled__[match.schema].normalize(match, this)
|
||||
result.push(match)
|
||||
lastIndex = candidate.lastIndex
|
||||
}
|
||||
|
||||
if (result.length) {
|
||||
@@ -47751,10 +47897,6 @@ LinkifyIt.prototype.match = function match (text) {
|
||||
* of the string, and null otherwise.
|
||||
**/
|
||||
LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
|
||||
// Reset scan cache
|
||||
this.__text_cache__ = text
|
||||
this.__index__ = -1
|
||||
|
||||
if (!text.length) return null
|
||||
|
||||
const m = this.re.schema_at_start.exec(text)
|
||||
@@ -47763,11 +47905,10 @@ LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
|
||||
const len = this.testSchemaAt(text, m[2], m[0].length)
|
||||
if (!len) return null
|
||||
|
||||
this.__schema__ = m[2]
|
||||
this.__index__ = m.index + m[1].length
|
||||
this.__last_index__ = m.index + m[0].length + len
|
||||
const match = new Match(text, m[2], m.index + m[1].length, m.index + m[0].length + len)
|
||||
|
||||
return createMatch(this, 0)
|
||||
this.__compiled__[match.schema].normalize(match, this)
|
||||
return match
|
||||
}
|
||||
|
||||
/** chainable
|
||||
|
||||
Generated
+54
-41
@@ -380,9 +380,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "8.59.3",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.59.3.tgz",
|
||||
"integrity": "sha512-ePFoH0g4ludssdRFqqDxQePCxU4WQyRa9+XVwjm7yLn0FKhMeoetC+qBEEI1Eyb1pGSDveTIT09Bvw2WhlGayg==",
|
||||
"version": "8.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.62.0.tgz",
|
||||
"integrity": "sha512-KvAclkktORPvM54TgLgA4z9HIV1M8zOgw9ZVNXl9f/8dLYfXYX1wkMXP7qmabpijQRV5bHJLOmoyGQbLMaUYeg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -404,9 +404,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.16.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
|
||||
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
|
||||
"version": "8.17.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.17.0.tgz",
|
||||
"integrity": "sha512-xRQbDb9BnwDafYNn6Vwl839DYVjqXYb1XVGtWAZ1kcDc6iwAL4hg3B1dZlRiuENFeO2H53gFG3in621AdERVAg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
@@ -472,9 +472,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/baseline-browser-mapping": {
|
||||
"version": "2.10.30",
|
||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.30.tgz",
|
||||
"integrity": "sha512-xjOFN16Ha1+Rz4nFYKqHU/LSB+gx/Vi3yQLX7r7sAW+Wa+8hhF2h4pvqTrTMc8+WcDBEunnUurr46Jvv0jk3Vg==",
|
||||
"version": "2.10.40",
|
||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.40.tgz",
|
||||
"integrity": "sha512-BSSLZ9/Cjjv7Gtj5B68ZzXcXUg8iOf3fme+FCuh8rC/Go+Kmh8cox7M3A8dolou16s64QjLPOSdngh7GxXvkSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
@@ -510,9 +510,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/browserslist": {
|
||||
"version": "4.28.2",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.2.tgz",
|
||||
"integrity": "sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==",
|
||||
"version": "4.28.4",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.4.tgz",
|
||||
"integrity": "sha512-MTc8i/x9jBQd1iMw2CFGS+rwMa07eYjLR0CCTLDACl9xhxy+nIs3KeML/biicXtk9JrZ6dnnTatmc7ErPXIxqw==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@@ -530,10 +530,10 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"baseline-browser-mapping": "^2.10.12",
|
||||
"caniuse-lite": "^1.0.30001782",
|
||||
"electron-to-chromium": "^1.5.328",
|
||||
"node-releases": "^2.0.36",
|
||||
"baseline-browser-mapping": "^2.10.38",
|
||||
"caniuse-lite": "^1.0.30001799",
|
||||
"electron-to-chromium": "^1.5.376",
|
||||
"node-releases": "^2.0.48",
|
||||
"update-browserslist-db": "^1.2.3"
|
||||
},
|
||||
"bin": {
|
||||
@@ -557,9 +557,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/caniuse-lite": {
|
||||
"version": "1.0.30001792",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001792.tgz",
|
||||
"integrity": "sha512-hVLMUZFgR4JJ6ACt1uEESvQN1/dBVqPAKY0hgrV70eN3391K6juAfTjKZLKvOMsx8PxA7gsY1/tLMMTcfFLLpw==",
|
||||
"version": "1.0.30001799",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001799.tgz",
|
||||
"integrity": "sha512-hG1bReV+OUU+MOqK4t/ZWI0tZOyz3rqS9XuhOUz1cIcbwBKjOyJEJuw9ER5JuNyqxNk8u/JUVbGibBOL1yrjFw==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@@ -741,16 +741,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.5.357",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.357.tgz",
|
||||
"integrity": "sha512-NHlTIQDK8fmVwHwuIzmXYEJ1Ewq3D9wDNc0cWXxDGysP6Pb21giwGNkxiTifyKy/4SoPuN5l6GLP1W9Sv7zB2g==",
|
||||
"version": "1.5.380",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.380.tgz",
|
||||
"integrity": "sha512-W6d5AbuEoRayO447cqrg6lKJIlscgRnnxOZl/08kfV71BQDoEBC7Wwis68z87LjyK6f4kWyTaubuDbhHKrZkbA==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/enhanced-resolve": {
|
||||
"version": "5.21.3",
|
||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.21.3.tgz",
|
||||
"integrity": "sha512-QyL119InA+XXEkNLNTPCXPugSvOfhwv0JOlGNzvxs0hZaiHLNvXSpudUWsOlsXGWJh8G6ckCScEkVHfX3kw/2Q==",
|
||||
"version": "5.24.1",
|
||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.24.1.tgz",
|
||||
"integrity": "sha512-7DdUaTjmNwMcH2gLr1qycesKII3BK4RLy/mdAb7x10Lq7bR4aNKHt1BR1ZALSv0rPM/hF5wYF0PhGop/rJm8vw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -964,9 +964,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-unicorn/node_modules/globals": {
|
||||
"version": "17.6.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-17.6.0.tgz",
|
||||
"integrity": "sha512-sepffkT8stwnIYbsMBpoCHJuJM5l98FUF2AnE07hfvE0m/qp3R586hw4jF4uadbhvg1ooIdzuu7CsfD2jzCaNA==",
|
||||
"version": "17.7.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-17.7.0.tgz",
|
||||
"integrity": "sha512-Czmyns5dUsq4seFBR/Kdydhmo8y9kC79hiSkPn0YcGtNnYWnrgt0vjrSjx9tspoDGWm2CMarffRuLjM4xUz8xg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -1575,9 +1575,19 @@
|
||||
}
|
||||
},
|
||||
"node_modules/linkify-it": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz",
|
||||
"integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==",
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.1.tgz",
|
||||
"integrity": "sha512-wVoTjP4Q6R0NW5hiZkVJaFZPWgtXfoGF+6LucL3/FtiNjmcHhYjEr5f1Kqjirc1nBW07J/ZuRFumqr2oqccEWg==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/puzrin"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/markdown-it"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"uc.micro": "^2.0.0"
|
||||
@@ -2258,11 +2268,14 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-releases": {
|
||||
"version": "2.0.44",
|
||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.44.tgz",
|
||||
"integrity": "sha512-5WUyunoPMsvvEhS8AxHtRzP+oA8UCkJ7YRxatWKjngndhDGLiqEVAQKWjFAiAiuL8zMRGzGSJxFnLetoa43qGQ==",
|
||||
"version": "2.0.50",
|
||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.50.tgz",
|
||||
"integrity": "sha512-J6l92tKHX6w8Jy5nO1Vuc01NoIiRGi/d6qBKVxh+IQ8Cr3b6HbVNfKiF8ZpFKufTwpwxMmce2W3iQZ861ZRyTg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
"version": "0.9.4",
|
||||
@@ -2433,9 +2446,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/regjsparser": {
|
||||
"version": "0.13.1",
|
||||
"resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.1.tgz",
|
||||
"integrity": "sha512-dLsljMd9sqwRkby8zhO1gSg3PnJIBFid8f4CQj/sXx+7cKx+E7u0PKhZ+U4wmhx7EfmtvnA318oVaIkAB1lRJw==",
|
||||
"version": "0.13.2",
|
||||
"resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.2.tgz",
|
||||
"integrity": "sha512-NgRBy2Nx/bE+9F27nVHnqcN5HjyLmecqsqx2PJHu3/IEtADD4WuxuXIVExD5PoSDFVrl78dOonfcOe5O+5nbzQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
@@ -2647,9 +2660,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "6.25.0",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.25.0.tgz",
|
||||
"integrity": "sha512-ZgpWDC5gmNiuY9CnLVXEH8rl50xhRCuLNA97fAUnKi8RRuV4E6KG31pDTsLVUKnohJE0I3XDrTeEydAXRw47xg==",
|
||||
"version": "6.27.0",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.27.0.tgz",
|
||||
"integrity": "sha512-YmfV3YnEDzXRC5lZ2jWtWWHKGUm1zIt8AhesR1tens+HTNv+YZlN/dp6G727LOvMJ8xjP9Be7Y2Sdr96LDm+pg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.17"
|
||||
|
||||
Reference in New Issue
Block a user