Skip to content

Commit

Permalink
chore: Moving schema to here
Browse files Browse the repository at this point in the history
  • Loading branch information
PRO-2684 committed Jan 3, 2025
1 parent c100869 commit 8ff120b
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"*.json",
"!settings.json",
"!list.json",
"!list.min.json"
"!list.min.json",
"!ruleset.schema.json"
],
"url": "https://github.com/PRO-2684/pURLfy/raw/refs/heads/main/ruleset.schema.json"
"url": "/ruleset.schema.json"
}
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ English | [简体中文](README_zh.md)

[![jsDelivr hits](https://data.jsdelivr.com/v1/package/gh/PRO-2684/pURLfy-rules/badge?style=rounded)](https://www.jsdelivr.com/package/gh/PRO-2684/pURLfy-rules?tab=stats)

Rulesets for [pURLfy](https://github.com/PRO-2684/pURLfy). Description on structure of rulesets can be found in [pURLfy's README](https://github.com/PRO-2684/pURLfy/#-rulesets), and formal definition of the format can be found at [`ruleset.schema.json`](https://github.com/PRO-2684/pURLfy/blob/main/ruleset.schema.json).

Rulesets for [pURLfy](https://github.com/PRO-2684/pURLfy). Description on structure of rulesets can be found in [pURLfy's README](https://github.com/PRO-2684/pURLfy/#-rulesets), and formal definition of the format can be found at [`ruleset.schema.json`](ruleset.schema.json).

## 📃 Files

- [ruleset.schema.json](ruleset.schema.json): The formal definition of the format of rulesets.
- [list.json](list.json): A list of all rulesets.
- [tracking.json](tracking.json): Rules for purifying tracking links.
- [outgoing.json](outgoing.json): Rules for purifying outgoing links.
Expand Down
3 changes: 2 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

[![jsDelivr hits](https://data.jsdelivr.com/v1/package/gh/PRO-2684/pURLfy-rules/badge?style=rounded)](https://www.jsdelivr.com/package/gh/PRO-2684/pURLfy-rules?tab=stats)

[pURLfy](https://github.com/PRO-2684/pURLfy) 的规则集。有关规则集结构的描述,请参阅 [pURLfy 的 README](https://github.com/PRO-2684/pURLfy/blob/main/README_zh.md#-%E8%A7%84%E5%88%99%E9%9B%86);格式的形式化定义可以参考 [`ruleset.schema.json`](https://github.com/PRO-2684/pURLfy/blob/main/ruleset.schema.json)
[pURLfy](https://github.com/PRO-2684/pURLfy) 的规则集。有关规则集结构的描述,请参阅 [pURLfy 的 README](https://github.com/PRO-2684/pURLfy/blob/main/README_zh.md#-%E8%A7%84%E5%88%99%E9%9B%86);格式的形式化定义可以参考 [`ruleset.schema.json`](ruleset.schema.json)

## 📃 文件

- [ruleset.schema.json](ruleset.schema.json): 规则集格式的形式化定义。
- [list.json](list.json): 所有规则集的列表。
- [tracking.json](tracking.json): 净化跟踪链接的规则。
- [outgoing.json](outgoing.json): 净化外链的规则。
Expand Down
217 changes: 217 additions & 0 deletions ruleset.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Ruleset Schema",
"type": "object",
"$ref": "#/definitions/intermediate",
"definitions": {
"rule": {
"type": "object",
"title": "Rule",
"description": "A single rule.",
"properties": {
"mode": {
"type": "string",
"title": "Mode",
"description": "Mode of the rule.",
"enum": [
"white",
"black",
"param",
"regex",
"redirect",
"visit",
"lambda"
]
},
"description": {
"type": "string",
"title": "Description",
"description": "Description of the rule."
},
"author": {
"type": "string",
"title": "Author",
"description": "Author of the rule."
},
"std": {
"type": "boolean",
"title": "Standard",
"description": "Whether the URL search string shall be deemed standard."
},
"params": {
"type": "array",
"title": "Params",
"description": "List of parameters to be kept, removed or processed.",
"items": {
"type": "string"
}
},
"acts": {
"type": "array",
"title": "Acts",
"description": "List of actions to be performed.",
"items": {
"type": "string"
}
},
"regex": {
"type": "array",
"title": "Regex",
"description": "List of regular expressions to be matched.",
"items": {
"type": "string"
}
},
"replace": {
"type": "array",
"title": "Replace",
"description": "List of strings to replace matched parts.",
"items": {
"type": "string"
}
},
"headers": {
"type": "object",
"title": "Headers",
"description": "The headers to use for web requests.",
"additionalProperties": {
"type": "string"
}
},
"lambda": {
"type": "string",
"title": "Lambda",
"description": "The lambda function to use for processing."
},
"continue": {
"type": "boolean",
"title": "Continue",
"description": "Whether to continue processing the URL."
}
},
"required": [
"mode",
"description",
"author"
],
"allOf": [
{
"if": {
"properties": {
"mode": {
"const": "white"
}
}
},
"then": {
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"mode": {
"const": "black"
}
}
},
"then": {
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"mode": {
"const": "param"
}
}
},
"then": {
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"mode": {
"const": "regex"
}
}
},
"then": {
"required": [
"regex",
"replace"
]
}
},
{
"if": {
"properties": {
"mode": {
"const": "redirect"
}
}
},
"then": {
"required": []
}
},
{
"if": {
"properties": {
"mode": {
"const": "visit"
}
}
},
"then": {
"required": []
}
},
{
"if": {
"properties": {
"mode": {
"const": "lambda"
}
}
},
"then": {
"required": [
"lambda"
]
}
}
],
"additionalProperties": false
},
"intermediate": {
"type": "object",
"title": "Intermediate",
"description": "An intermediate object. Expects another intermediate if ends with a slash, otherwise a rule.",
"patternProperties": {
"^[^/]+/$": {
"$ref": "#/definitions/intermediate"
},
"^[^/]*$": {
"$ref": "#/definitions/rule"
},
"^/.+/$": {
"$ref": "#/definitions/intermediate"
},
"^/.+[^/]$": {
"$ref": "#/definitions/rule"
}
}
}
},
"additionalProperties": false
}

0 comments on commit 8ff120b

Please sign in to comment.