Compare commits

...

3 Commits

Author SHA1 Message Date
tdc
5f29a595f0 解決 wildcard 問題 2025-04-15 12:01:42 +08:00
tdc
ac3ac2b63a 處理 wildcard 問題 2025-04-15 11:56:57 +08:00
踢低吸
29c8a67b9e
Update hosts.txt 2025-04-15 10:21:48 +08:00

View File

@ -79,9 +79,10 @@ async def to_hosts(filename: str, data: str, newversion: str):
with open(newfilename, "w") as output:
if name == "hosts":
pattern = r"(?<=^\|\|)\S+\.\S{2,}(?=\^)"
newoutput = "\n".join(
"0.0.0.0 " + e for e in re.findall(pattern, newdata, re.MULTILINE)
)
newoutput = ""
for e in re.findall(pattern, newdata, re.MULTILINE):
if "*" not in e:
newoutput += "0.0.0.0 " + e + "\n"
else:
newoutput = "\n".join("0.0.0.0 " + e for e in data)
output.write(newhead)