melhorias de url
This commit is contained in:
parent
cb86027ff9
commit
3b45b82654
5 changed files with 18 additions and 6 deletions
|
|
@ -9,7 +9,7 @@
|
|||
* parametros = {nome:"José"}
|
||||
*/
|
||||
|
||||
export class TipagemRotas<T extends { [q: string]: string | undefined }> {
|
||||
export class TipagemRotas<T extends { [q: string]: any }> {
|
||||
_partesCaminho: string[] = []
|
||||
_acaoIr?: (endereco: string) => undefined
|
||||
rotulo: string | undefined
|
||||
|
|
@ -76,7 +76,7 @@ export class TipagemRotas<T extends { [q: string]: string | undefined }> {
|
|||
for (const [key, value] of queryKeys) {
|
||||
url.searchParams.set(
|
||||
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
|
||||
}
|
||||
|
||||
for (const chave in queryObj) {
|
||||
try {
|
||||
queryObj[chave] = JSON.parse(queryObj[chave])
|
||||
} catch {}
|
||||
}
|
||||
|
||||
return queryObj as Partial<T>
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue