mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-12-05 08:03:01 +00:00
插件 API v1 的元数据校验、utils、moejs 执行层和任务钩子的结果解析搬到 嵌套模块 github.com/QuantumNous/new-api/pluginkit,按 pluginkit/vX.Y.Z 打标签发布,其他宿主可以直接引用同一份实现。 - pkg/jsplugin 只留注册表、路由和 CLI,现有导出名通过别名保留,行为不变 - 文档 v1.md、v1.d.ts、v1.schema.json 移到 pluginkit/,schema 和类型由模块内嵌 - 请求处理钩子新增宿主专有的 ctx.client、ctx.session,new-api 不提供 - 导出 MaxPluginKeyLength、NewAPIReservedKeys 和 CallPathJSONInto - CI、Makefile、Dockerfile 和 AGENTS.md 按 relaykit 的方式加上 pluginkit
27 lines
628 B
Go
27 lines
628 B
Go
package pluginkit
|
||
|
||
// asciiFold maps only 'A'–'Z' onto 'a'–'z'. Every other byte is unchanged.
|
||
// Unicode case folding is intentionally not applied: U+212A (KELVIN SIGN)
|
||
// must not become 'k' and impersonate an ASCII model name.
|
||
func asciiFold(s string) string {
|
||
var buf []byte
|
||
for i := 0; i < len(s); i++ {
|
||
c := s[i]
|
||
if c >= 'A' && c <= 'Z' {
|
||
if buf == nil {
|
||
buf = []byte(s)
|
||
}
|
||
buf[i] = c + ('a' - 'A')
|
||
}
|
||
}
|
||
if buf == nil {
|
||
return s
|
||
}
|
||
return string(buf)
|
||
}
|
||
|
||
// ASCIIFold is the exported form of asciiFold for consumers outside this package.
|
||
func ASCIIFold(s string) string {
|
||
return asciiFold(s)
|
||
}
|