mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
Merge pull request #216 from nikhilbadyal/bug/slugify
🐛 Removed invalid char in output file
This commit is contained in:
+2
-2
@@ -8,7 +8,7 @@ from loguru import logger
|
|||||||
|
|
||||||
from src.config import RevancedConfig
|
from src.config import RevancedConfig
|
||||||
from src.patches import Patches
|
from src.patches import Patches
|
||||||
from src.utils import possible_archs
|
from src.utils import possible_archs, slugify
|
||||||
|
|
||||||
|
|
||||||
class Parser(object):
|
class Parser(object):
|
||||||
@@ -100,7 +100,7 @@ class Parser(object):
|
|||||||
"-m",
|
"-m",
|
||||||
integrations,
|
integrations,
|
||||||
"-o",
|
"-o",
|
||||||
f"Re-{app}-{version}{output_prefix}output.apk",
|
f"Re-{app}-{slugify(version)}{output_prefix}output.apk",
|
||||||
"--keystore",
|
"--keystore",
|
||||||
self.config.keystore_name,
|
self.config.keystore_name,
|
||||||
"--options",
|
"--options",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Utilities."""
|
"""Utilities."""
|
||||||
|
import re
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
@@ -55,3 +56,23 @@ def handle_response(response: Response) -> None:
|
|||||||
if response_code != 200:
|
if response_code != 200:
|
||||||
logger.error(response.text)
|
logger.error(response.text)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def slugify(string: str) -> str:
|
||||||
|
"""Converts a string to a slug format."""
|
||||||
|
# Convert to lowercase
|
||||||
|
string = string.lower()
|
||||||
|
|
||||||
|
# Remove special characters
|
||||||
|
string = re.sub(r"[^\w\s-]", "", string)
|
||||||
|
|
||||||
|
# Replace spaces with dashes
|
||||||
|
string = re.sub(r"\s+", "-", string)
|
||||||
|
|
||||||
|
# Remove consecutive dashes
|
||||||
|
string = re.sub(r"-+", "-", string)
|
||||||
|
|
||||||
|
# Remove leading and trailing dashes
|
||||||
|
string = string.strip("-")
|
||||||
|
|
||||||
|
return string
|
||||||
|
|||||||
Reference in New Issue
Block a user