Ver código fonte

ref: some minor details

Sv443 1 mês atrás
pai
commit
693843a621
2 arquivos alterados com 4 adições e 4 exclusões
  1. 3 3
      src/serializer.ts
  2. 1 1
      src/utils/xhr.ts

+ 3 - 3
src/serializer.ts

@@ -1,4 +1,4 @@
-import { DataStoreSerializer } from "@sv443-network/userutils";
+import { DataStoreSerializer, type Stringifiable } from "@sv443-network/userutils";
 
 import { configStore } from "./config.js";
 import { autoLikeStore } from "./features/input.js";
@@ -59,10 +59,10 @@ export async function importData(blob: File | Blob) {
 export async function downloadData() {
   const serializer = getStoreSerializer();
 
-  const pad = (num: number, len = 2) => String(num).padStart(len, "0");
+  const pad = (val: Stringifiable, len = 2) => String(val).padStart(len, "0");
 
   const d = new Date();
-  const dateStr = `${pad(d.getFullYear(), 4)}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}_${pad(d.getHours())}-${pad(d.getMinutes())}`;
+  const dateStr = `${pad(d.getFullYear(), 4)}${pad(d.getMonth() + 1)}${pad(d.getDate())}_${pad(d.getHours())}${pad(d.getMinutes())}`;
   const fileName = `BetterYTM ${packageJson.version} data export ${dateStr}.json`;
 
   const data = JSON.stringify(JSON.parse(await serializer.serialize()), undefined, 2);

+ 1 - 1
src/utils/xhr.ts

@@ -21,7 +21,7 @@ export function constructUrlString(baseUrl: string, params: Record<string, Strin
 /**
  * Constructs a URL object from a base URL and a record of query parameters.  
  * If a value is null, the parameter will be valueless. If a value is undefined, the parameter will be omitted.  
- * All values will be URI-encoded.  
+ * All values will be stringified and then URI-encoded.  
  * @returns Returns a URL object instead of a string
  */
 export function constructUrl(base: string, params: Record<string, Stringifiable | null>) {