@domql/router 2.5.94 → 2.5.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -46,6 +46,7 @@ const defaultOptions = {
46
46
  useFragment: false,
47
47
  updateState: true,
48
48
  scrollToOffset: 0,
49
+ contentElementKey: "content",
49
50
  scrollToOptions: { behavior: "smooth" }
50
51
  };
51
52
  const router = (path, element, state = {}, passedOptions = {}) => {
@@ -54,7 +55,8 @@ const router = (path, element, state = {}, passedOptions = {}) => {
54
55
  const options = { ...defaultOptions, ...element.context.routerOptions, ...passedOptions };
55
56
  lastLevel = options.lastLevel;
56
57
  const contentElementKey = options.contentElementKey;
57
- const [pathname, hash] = path.split("#");
58
+ const urlObj = new win.URL(win.location.origin + path);
59
+ const { pathname, search, hash } = urlObj;
58
60
  const rootNode = element.node;
59
61
  const route = getActiveRoute(options.level, pathname);
60
62
  const content = element.routes[route || "/"] || element.routes["/*"];
@@ -67,7 +69,7 @@ const router = (path, element, state = {}, passedOptions = {}) => {
67
69
  return;
68
70
  }
69
71
  if (options.pushState) {
70
- win.history.pushState(state, null, pathname + (hash ? `#${hash}` : ""));
72
+ win.history.pushState(state, null, pathname + (search || "") + (hash || ""));
71
73
  }
72
74
  if (pathChanged || !hashChanged) {
73
75
  if (options.updateState) {
package/index.js CHANGED
@@ -23,6 +23,7 @@ const defaultOptions = {
23
23
  useFragment: false,
24
24
  updateState: true,
25
25
  scrollToOffset: 0,
26
+ contentElementKey: 'content',
26
27
  scrollToOptions: { behavior: 'smooth' }
27
28
  }
28
29
 
@@ -38,7 +39,8 @@ export const router = (
38
39
  lastLevel = options.lastLevel
39
40
  const contentElementKey = options.contentElementKey
40
41
 
41
- const [pathname, hash] = path.split('#')
42
+ const urlObj = new win.URL(win.location.origin + path)
43
+ const { pathname, search, hash } = urlObj
42
44
 
43
45
  const rootNode = element.node
44
46
  const route = getActiveRoute(options.level, pathname)
@@ -52,8 +54,9 @@ export const router = (
52
54
  element.state.root.debugging = false
53
55
  return
54
56
  }
57
+
55
58
  if (options.pushState) {
56
- win.history.pushState(state, null, pathname + (hash ? `#${hash}` : ''))
59
+ win.history.pushState(state, null, pathname + (search || '') + (hash || ''))
57
60
  }
58
61
 
59
62
  if (pathChanged || !hashChanged) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/router",
3
- "version": "2.5.94",
3
+ "version": "2.5.131",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
@@ -25,7 +25,7 @@
25
25
  "@domql/globals": "latest",
26
26
  "@domql/utils": "latest"
27
27
  },
28
- "gitHead": "76edeab829524b706fd1a0bd3fac3fd5563a3b84",
28
+ "gitHead": "ede2477daecd2192a473223cfea69bf7363c6e02",
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.12.0"
31
31
  }