js-mvc-framework
Advanced tools
Comparing version 1.2.29 to 1.2.30
@@ -39,6 +39,6 @@ import { Control } from '/dependencies/mvc-framework.js' | ||
default: { | ||
hashpath: true, | ||
routes: { | ||
"base": "/static-cms/", | ||
"hashpath": true, | ||
"routes": { | ||
"": { | ||
"base": "/static-cms/", | ||
"pathname": "", | ||
@@ -49,3 +49,2 @@ "name": "index-alias", | ||
"/": { | ||
"base": "/static-cms/", | ||
"pathname": "/", | ||
@@ -56,3 +55,2 @@ "name": "index", | ||
"/:subpageID": { | ||
"base": "/static-cms/", | ||
"pathname": "/:subpageID", | ||
@@ -69,2 +67,3 @@ "name": "subpage", | ||
this.routers.location.default.navigate() | ||
// window.location.assign(window.location) | ||
}, | ||
@@ -71,0 +70,0 @@ "routers.location.default route": function route($event) { |
@@ -26,2 +26,3 @@ import { recursiveAssign } from '../../Coutil/index.js' | ||
} | ||
get base() { return this.settings.base } | ||
get window() { | ||
@@ -64,21 +65,24 @@ if(this.#_window !== undefined) return this.#_window | ||
if(this.#_boundPopState !== undefined) return this.#_boundPopState | ||
this.#_boundPopState = this.#popState.bind(this) | ||
this.#_boundPopState = function popState($event) { | ||
return this.navigate(this.window.location.href, null) | ||
}.bind(this) | ||
return this.#_boundPopState | ||
} | ||
#popState($event) { | ||
this.navigate($event.currentTarget.location) | ||
return this | ||
} | ||
navigate($path, $method = "assign") { | ||
$path = ($path === undefined) ? String(this.window.location) : String($path) | ||
const url = new URL($path) | ||
navigate($path, $method) { | ||
$path = ($path !== undefined) ? new URL($path) : this.window.location | ||
let path | ||
if(this.hashpath) { path = $path.hash.slice(1) } | ||
else { | ||
path = $path.href | ||
.replace(new RegExp(`^${this.window.origin}`), '') | ||
.replace(new RegExp(`^${this.base}`), '') | ||
} | ||
const base = [this.window.origin, this.base].join('') | ||
const url = new URL(path, base) | ||
const { pathname, hash, href, origin } = url | ||
const preterRoute = this.route | ||
if(preterRoute) { preterRoute.active = false } | ||
const path = (this.hashpath) ? hash.slice(1) : pathname | ||
const { route, location } = this.#matchRoute(path) | ||
if(route && route?.enable) { | ||
if(String(url) !== String(this.window.location)) { | ||
this.window.location[$method](url) | ||
} | ||
if($method) { this.window?.location[$method](path) } | ||
route.active = true | ||
@@ -85,0 +89,0 @@ location.state = this.window.history.state |
@@ -18,2 +18,3 @@ import { match } from '../../../node_modules/path-to-regexp/dist/index.js' | ||
} | ||
get base() { return this.#settings.base } | ||
get pathname() { return this.#settings.pathname } | ||
@@ -20,0 +21,0 @@ get enable() { |
{ | ||
"name": "js-mvc-framework", | ||
"author": "Thomas Patrick Welborn", | ||
"version": "1.2.29", | ||
"version": "1.2.30", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1691650
13067