Merge pull request #55 from hlqviet/fix/domain-processing

Fix domain processing
This commit is contained in:
mrrfv
2023-11-20 21:31:56 +01:00
committed by GitHub
3 changed files with 13 additions and 15 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
import { existsSync } from "fs";
import { resolve } from "path";
import { existsSync } from "node:fs";
import { resolve } from "node:path";
import {
createZeroTrustListsAtOnce,
+3 -3
View File
@@ -1,6 +1,6 @@
import { existsSync } from "fs";
import { unlink } from "fs/promises";
import { resolve } from "path";
import { existsSync } from "node:fs";
import { unlink } from "node:fs/promises";
import { resolve } from "node:path";
import {
LIST_TYPE,
+8 -10
View File
@@ -1,7 +1,8 @@
import { once } from "events";
import { ReadStream, createReadStream, createWriteStream } from "fs";
import { basename } from "path";
import { createInterface } from "readline";
import { once } from "node:events";
import { createReadStream, createWriteStream } from "node:fs";
import { basename } from "node:path";
import { createInterface } from "node:readline";
import { pipeline } from "node:stream/promises";
if (!globalThis.fetch) {
globalThis.fetch = (await import("node-fetch")).default;
@@ -12,7 +13,7 @@ if (!globalThis.fetch) {
* @param {string} value The value to be checked.
*/
export const isValidDomain = (value) =>
/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(
/^\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b$/.test(
value
);
@@ -56,11 +57,8 @@ export const downloadFiles = async (filePath, urls) => {
for (const response of responses) {
const writeStream = createWriteStream(filePath, { flags: "a" });
ReadStream.from(response.body)
.on("end", () => {
writeStream.write("\n");
})
.pipe(writeStream);
await pipeline(response.body, writeStream, { end: false });
writeStream.end("\n");
}
};