Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use regexp to check not a brand #72

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/selenium_profiles/scripts/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ def patch_version(self, useragent_profile: dict, version: str or bool or None =
# noinspection PyTypeChecker
metadata.update(profile["userAgentMetadata"])

brands_pattern = r'^Not[ (:-./);=?_]A[ (:-./);=?_]Brand$'
if metadata["brands"]:
brands = []
# noinspection PyTypeChecker
for brand in metadata["brands"]:
if not (brand["brand"] == "Not=A?Brand" or brand["brand"] == "Not)A;Brand"):
if not re.match(brands_pattern, brand["brand"]):
brand["version"] = version.split(".")[0]
brands.append(brand)
# noinspection PyTypeChecker
Expand All @@ -123,7 +124,7 @@ def patch_version(self, useragent_profile: dict, version: str or bool or None =
version_list = []
# noinspection PyTypeChecker
for i in metadata["fullVersionList"]:
if not (i["brand"] == "Not=A?Brand" or i["brand"] == "Not)A;Brand"):
if not re.match(brands_pattern, i["brand"]):
i["version"] = version
version_list.append(i)
# noinspection PyTypeChecker
Expand Down