fix(book): 修复文件名合法性检查问题
- 添加了去除文件名末尾空格和点号的功能 - 确保文件名不会以非法字符结尾
This commit is contained in:
@@ -51,6 +51,7 @@ class BookService:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def legitimate_naming(name: str) -> str:
|
def legitimate_naming(name: str) -> str:
|
||||||
"""将文件名中的非法字符替换为合法字符"""
|
"""将文件名中的非法字符替换为合法字符"""
|
||||||
|
name = name.rstrip(" .")
|
||||||
replacements = {":": ":", "<": "《", ">": "》", "/": " ", "\\": " ", "?": "?"}
|
replacements = {":": ":", "<": "《", ">": "》", "/": " ", "\\": " ", "?": "?"}
|
||||||
for old, new in replacements.items():
|
for old, new in replacements.items():
|
||||||
name = name.replace(old, new)
|
name = name.replace(old, new)
|
||||||
|
|||||||
Reference in New Issue
Block a user