🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

literaljs-router

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

literaljs-router - npm Package Compare versions

Comparing version

to
0.0.3

2

build/index.js

@@ -1,2 +0,2 @@

module.exports={Router:function(t){var n=t.path,r=t.routes;if(n||(n=window.location.pathname),(r=r.find(function(t){return t.path===n}))&&r.render)return history.pushState({},null,n),r.render()}};
module.exports={Router:function(t){var a=t.path,e=t.routes;a&&a!==location.pathname||(a=location.pathname+location.search+location.hash);var n=document.createElement("a");if(n.href=location.origin+a,(e=e.find(function(t){return"string"==typeof t.path&&(t.path=new RegExp("^"+t.path+"$","i")),n.pathname.match(t.path)}))&&e.render)return history.pushState({},null,n.pathname+n.search+n.hash),e.render()}};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

function t(t){var r=t.path,e=t.routes;if(r||(r=window.location.pathname),(e=e.find(function(t){return t.path===r}))&&e.render)return history.pushState({},null,r),e.render()}export default{Router:t};export{t as Router};
function t(t){var a=t.path,e=t.routes;a&&a!==location.pathname||(a=location.pathname+location.search+location.hash);var n=document.createElement("a");if(n.href=location.origin+a,(e=e.find(function(t){return"string"==typeof t.path&&(t.path=new RegExp("^"+t.path+"$","i")),n.pathname.match(t.path)}))&&e.render)return history.pushState({},null,n.pathname+n.search+n.hash),e.render()}export default{Router:t};export{t as Router};
//# sourceMappingURL=index.m.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.literaljsRouter=t()}(this,function(){return{Router:function(e){var t=e.path,n=e.routes;if(t||(t=window.location.pathname),(n=n.find(function(e){return e.path===t}))&&n.render)return history.pushState({},null,t),n.render()}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.literaljsRouter=t()}(this,function(){return{Router:function(e){var t=e.path,n=e.routes;t&&t!==location.pathname||(t=location.pathname+location.search+location.hash);var a=document.createElement("a");if(a.href=location.origin+t,(n=n.find(function(e){return"string"==typeof e.path&&(e.path=new RegExp("^"+e.path+"$","i")),a.pathname.match(e.path)}))&&n.render)return history.pushState({},null,a.pathname+a.search+a.hash),n.render()}}});
//# sourceMappingURL=index.umd.js.map
{
"name": "literaljs-router",
"version": "0.0.2",
"version": "0.0.3",
"description": "A router built to work with LiteralJS.",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -16,5 +16,5 @@ <p align="center">

Build output to build:
194 B: index.js
216 B: index.m.js
273 B: index.umd.js
350 B: index.js
363 B: index.m.js
424 B: index.umd.js
```
export function Router({ path, routes }) {
if (!path) path = window.location.pathname;
if (!path || path === location.pathname) {
// Loads the path and params if typed and provided initially
path = location.pathname + location.search + location.hash;
}
routes = routes.find(route => route.path === path);
const hrefParser = document.createElement('a');
hrefParser.href = location.origin + path;
routes = routes.find(route => {
if (typeof route.path === 'string') {
route.path = new RegExp('^' + route.path + '$', 'i');
}
return hrefParser.pathname.match(route.path);
});
if (routes && routes.render) {
history.pushState({}, null, path);
history.pushState(
{},
null,
hrefParser.pathname + hrefParser.search + hrefParser.hash
);
return routes.render();

@@ -8,0 +24,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet