This commit is contained in:
Luiz Silva 2026-02-08 20:30:35 -03:00
parent 0cbe901499
commit dbe0f66daf
51 changed files with 30 additions and 304 deletions

18
src/tipagemRotas.ts Normal file → Executable file
View file

@ -63,9 +63,10 @@ export class TipagemRotas<T extends { [q: string]: any }> {
*/
endereco(query: T, usarComoHash?: boolean) {
const url = new URL(
typeof window !== "undefined" ? window.location.href : "http://localhost",
)
const win =
(typeof globalThis !== "undefined" && (globalThis as any).window) ||
undefined
const url = new URL(win ? win.location.href : "http://localhost")
url.pathname = this.caminho
@ -95,8 +96,11 @@ export class TipagemRotas<T extends { [q: string]: any }> {
if (this._acaoIr) {
this._acaoIr(this.endereco({ ...query }))
} else {
if (typeof window != "undefined") {
window.location.href = this.endereco({ ...query })
const win =
(typeof globalThis !== "undefined" && (globalThis as any).window) ||
undefined
if (win) {
win.location.href = this.endereco({ ...query })
}
}
}
@ -110,8 +114,8 @@ export class TipagemRotas<T extends { [q: string]: any }> {
const url = urlEntrada
? new URL(urlEntrada)
: new URL(
typeof window !== "undefined"
? window.location.href
typeof globalThis !== "undefined" && (globalThis as any).window
? (globalThis as any).window.location.href
: "http://localhost",
)
const query = url.searchParams