【AI協調開発研究】 - AI二重化モデルの学術論文draft完成(workshop_paper_draft.md) - 「隠れた危機」分析とbirthの原則哲学化 - TyEnv「唯一の真実」協調会話を保存・研究資料に統合 - papers管理構造の整備(wip/under-review/published分離) 【Phase 10.9-β HostCall進捗】 - JitConfigBox: relax_numeric フラグ追加(i64→f64コアーション制御) - HostcallRegistryBox: 署名検証・白黒リスト・コアーション対応 - JitHostcallRegistryBox: Nyash側レジストリ操作API - Lower統合: env直読 → jit::config::current() 参照に統一 - 数値緩和設定: NYASH_JIT_HOSTCALL_RELAX_NUMERIC/Config.set_flag 【検証サンプル拡充】 - math.sin/cos/abs/min/max 関数スタイル(examples/jit_math_function_style_*.nyash) - 境界ケース: 署名不一致・コアーション許可・mutating拒否サンプル - E2E実証: String.length→allow, Array.push→fallback, math関数の署名一致観測 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const { tokenChars } = require('./validation');
|
|
|
|
/**
|
|
* Parses the `Sec-WebSocket-Protocol` header into a set of subprotocol names.
|
|
*
|
|
* @param {String} header The field value of the header
|
|
* @return {Set} The subprotocol names
|
|
* @public
|
|
*/
|
|
function parse(header) {
|
|
const protocols = new Set();
|
|
let start = -1;
|
|
let end = -1;
|
|
let i = 0;
|
|
|
|
for (i; i < header.length; i++) {
|
|
const code = header.charCodeAt(i);
|
|
|
|
if (end === -1 && tokenChars[code] === 1) {
|
|
if (start === -1) start = i;
|
|
} else if (
|
|
i !== 0 &&
|
|
(code === 0x20 /* ' ' */ || code === 0x09) /* '\t' */
|
|
) {
|
|
if (end === -1 && start !== -1) end = i;
|
|
} else if (code === 0x2c /* ',' */) {
|
|
if (start === -1) {
|
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
}
|
|
|
|
if (end === -1) end = i;
|
|
|
|
const protocol = header.slice(start, end);
|
|
|
|
if (protocols.has(protocol)) {
|
|
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
}
|
|
|
|
protocols.add(protocol);
|
|
start = end = -1;
|
|
} else {
|
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
}
|
|
}
|
|
|
|
if (start === -1 || end !== -1) {
|
|
throw new SyntaxError('Unexpected end of input');
|
|
}
|
|
|
|
const protocol = header.slice(start, i);
|
|
|
|
if (protocols.has(protocol)) {
|
|
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
}
|
|
|
|
protocols.add(protocol);
|
|
return protocols;
|
|
}
|
|
|
|
module.exports = { parse };
|