melhorias de url

This commit is contained in:
Luiz Silva 2025-09-08 14:03:35 -03:00
parent cb86027ff9
commit 3b45b82654
5 changed files with 18 additions and 6 deletions

View file

@ -65,7 +65,7 @@ class TipagemRotas {
for (const [key, value] of queryKeys) { for (const [key, value] of queryKeys) {
url.searchParams.set( url.searchParams.set(
String(key), String(key),
value === void 0 || value === null ? "" : value encodeURIComponent(JSON.stringify(value))
); );
} }
url.hash = ""; url.hash = "";
@ -105,6 +105,12 @@ class TipagemRotas {
); );
return { ...queryObj, ...hashObj }; return { ...queryObj, ...hashObj };
} }
for (const chave in queryObj) {
try {
queryObj[chave] = JSON.parse(queryObj[chave]);
} catch {
}
}
return queryObj; return queryObj;
} }
} }

View file

@ -157,7 +157,7 @@ declare const texto_busca: (...texto: any[]) => string;
* parametros = {nome:"José"} * parametros = {nome:"José"}
*/ */
declare class TipagemRotas<T extends { declare class TipagemRotas<T extends {
[q: string]: string | undefined; [q: string]: any;
}> { }> {
_partesCaminho: string[]; _partesCaminho: string[];
_acaoIr?: (endereco: string) => undefined; _acaoIr?: (endereco: string) => undefined;

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "p-comuns", "name": "p-comuns",
"version": "0.223.0", "version": "0.224.0",
"description": "", "description": "",
"main": "./dist-back/index.js", "main": "./dist-back/index.js",
"module": "./dist-front/index.mjs", "module": "./dist-front/index.mjs",

View file

@ -9,7 +9,7 @@
* parametros = {nome:"José"} * parametros = {nome:"José"}
*/ */
export class TipagemRotas<T extends { [q: string]: string | undefined }> { export class TipagemRotas<T extends { [q: string]: any }> {
_partesCaminho: string[] = [] _partesCaminho: string[] = []
_acaoIr?: (endereco: string) => undefined _acaoIr?: (endereco: string) => undefined
rotulo: string | undefined rotulo: string | undefined
@ -76,7 +76,7 @@ export class TipagemRotas<T extends { [q: string]: string | undefined }> {
for (const [key, value] of queryKeys) { for (const [key, value] of queryKeys) {
url.searchParams.set( url.searchParams.set(
String(key), String(key),
value === undefined || value === null ? "" : value, encodeURIComponent(JSON.stringify(value)),
) )
} }
@ -125,6 +125,12 @@ export class TipagemRotas<T extends { [q: string]: string | undefined }> {
return { ...queryObj, ...hashObj } as T return { ...queryObj, ...hashObj } as T
} }
for (const chave in queryObj) {
try {
queryObj[chave] = JSON.parse(queryObj[chave])
} catch {}
}
return queryObj as Partial<T> return queryObj as Partial<T>
} }
} }