Skip to content

Commit

Permalink
Merge pull request #176 from mlec1/main
Browse files Browse the repository at this point in the history
refactor: Make all requiresCategory and scriptSrc fields an array
  • Loading branch information
enthec-opensource authored Jul 9, 2024
2 parents b2d6a1a + 7de5889 commit 43d22cd
Show file tree
Hide file tree
Showing 29 changed files with 5,719 additions and 1,935 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/scripts/technology_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,12 @@ class StringOrArrayOrDictValidator(AbstractValidator):
def get_type(self) -> list[Type]:
return [str, list, dict]


class IntOrArrayValidator(AbstractValidator):
def get_type(self) -> list[Type]:
return [int, list]


class DictValidator(RegexValidator):
def get_type(self) -> list[Type]:
return [dict]


class CategoryValidator(IntOrArrayValidator):
class CategoryValidator(ArrayValidator):
def __init__(self, categories: list[int], required: bool = False):
super().__init__(required)
self._categories: Final[list[int]] = categories
Expand All @@ -179,8 +173,6 @@ def _validate(self, tech_name: str, data: Any) -> bool:
type_validator: bool = super()._validate(tech_name, data)
if not type_validator:
return False
if isinstance(data, int):
data = [data]
for category_id in data:
if category_id not in self._categories:
self._set_custom_error(CategoryNotFoundException(f"The category '{category_id}' for tech '{tech_name}' does not exist!"))
Expand Down Expand Up @@ -260,7 +252,7 @@ def __init__(self, file_name: str):
"url": StringOrArrayValidator(contains_regex=True),
"xhr": StringOrArrayValidator(contains_regex=True),
"meta": DictValidator(contains_regex=True),
"scriptSrc": StringOrArrayValidator(contains_regex=True),
"scriptSrc": ArrayValidator(contains_regex=True),
"scripts": StringOrArrayValidator(contains_regex=True),
"html": ArrayValidator(contains_regex=True),
"certIssuer": StringValidator()
Expand Down
30 changes: 8 additions & 22 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,10 @@
}
},
"requiresCategory": {
"oneOf": [
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "number"
}
]
"type": "array",
"items": {
"type": "number"
}
},
"meta": {
"type": "object",
Expand All @@ -185,17 +178,10 @@
}
},
"scriptSrc": {
"oneOf": [
{
"type": "array",
"items": {
"$ref": "#/definitions/non-empty-non-blank-string"
}
},
{
"$ref": "#/definitions/non-empty-non-blank-string"
}
]
"type": "array",
"items": {
"$ref": "#/definitions/non-empty-non-blank-string"
}
},
"scripts": {
"oneOf": [
Expand Down
28 changes: 21 additions & 7 deletions src/technologies/_.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"recurring"
],
"saas": true,
"scriptSrc": "bitrix(?:\\.info/|/js/main/core)",
"scriptSrc": [
"bitrix(?:\\.info/|/js/main/core)"
],
"website": "https://www.1c-bitrix.ru"
},
"2B Advice": {
Expand All @@ -37,7 +39,9 @@
"BBCookieControler": ""
},
"saas": true,
"scriptSrc": "2badvice-cdn\\.azureedge\\.net",
"scriptSrc": [
"2badvice-cdn\\.azureedge\\.net"
],
"website": "https://www.2b-advice.com/en/data-privacy-software/cookie-consent-plugin/"
},
"30namaPlayer": {
Expand Down Expand Up @@ -100,7 +104,9 @@
"poa"
],
"saas": true,
"scriptSrc": "4tellcdn\\.azureedge\\.net",
"scriptSrc": [
"4tellcdn\\.azureedge\\.net"
],
"website": "https://4-tell.com"
},
"42stores": {
Expand Down Expand Up @@ -150,7 +156,9 @@
"recurring",
"low"
],
"scriptSrc": "\\.5centscdn\\.com/",
"scriptSrc": [
"\\.5centscdn\\.com/"
],
"website": "https://www.5centscdn.net"
},
"6sense": {
Expand All @@ -169,7 +177,9 @@
"recurring"
],
"saas": true,
"scriptSrc": "\\.6sc\\.co/",
"scriptSrc": [
"\\.6sc\\.co/"
],
"website": "https://6sense.com"
},
"8base": {
Expand All @@ -196,7 +206,9 @@
"dom": "model-viewer",
"icon": "model-viewer.svg",
"oss": true,
"scriptSrc": "/model-viewer/dist/model-viewer\\.min\\.js",
"scriptSrc": [
"/model-viewer/dist/model-viewer\\.min\\.js"
],
"website": "https://modelviewer.dev"
},
"@sulu/web": {
Expand All @@ -219,7 +231,9 @@
"_hyperscript": ""
},
"oss": true,
"scriptSrc": "//unpkg\\.com/hyperscript\\.org@([\\d\\.]+)\\;version:\\1",
"scriptSrc": [
"//unpkg\\.com/hyperscript\\.org@([\\d\\.]+)\\;version:\\1"
],
"website": "https://hyperscript.org"
}
}
Loading

0 comments on commit 43d22cd

Please sign in to comment.