New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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 0.0.5 to 0.0.6

2

build/index.js

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

var t=!1,a=!1,e=!0;module.exports={Router:function(n){var o=n.path,r=n.routes,h=n.key;void 0===h&&(h="location");var i=n.set;t||(t=!0,window.onpopstate=function(t){var e;a=!0;var n=t.target.location;i(((e={})[h]=n.pathname+n.search+n.hash,e))}),o&&o!==location.pathname||(o=location.pathname+location.search+location.hash);var c=document.createElement("a");c.href=location.origin+o;var s,p=c.pathname+c.search+c.hash;return r=r.find(function(t){return"string"==typeof t.path&&(t.path.match(/404/)&&(s=t),t.path=new RegExp("^"+t.path+"$","i")),c.pathname.match(t.path)}),a?a=!1:e?e=!1:history.pushState({},null,p),"object"==typeof r&&r.render?r.render():s?s.render():{element:"div",attributes:{class:"not-found"},children:["Not Found"]}},getParams:function(){if(!location.search)return{};for(var t,a={},e=location.search.substring(1).split("&"),n=0;n<e.length;n++)a[(t=e[n].split("="))[0]]=t[1];return a}};
var t,a=!1,e=!1,n=!0;module.exports={Router:function(o){var r=o.path,h=o.routes,i=o.key;void 0===i&&(i="location");var c=o.set;a||(a=!0,window.onpopstate=function(t){var a;e=!0;var n=t.target.location;c(((a={})[i]=n.pathname+n.search+n.hash,a))}),r&&r!==location.pathname||(r=location.pathname+location.search+location.hash);var s=document.createElement("a");s.href=location.origin+r;var p,l=s.pathname+s.search+s.hash;return h=h.find(function(t){return"string"==typeof t.path&&(t.path.match(/^404$/)&&(p=t),t.path=new RegExp("^"+t.path+"$","i")),s.pathname.match(t.path)}),e?e=!1:n?n=!1:t!==l&&history.pushState({},null,l),t=l,"object"==typeof h&&h.render?h.render():p?p.render():{element:"div",attributes:{class:"not-found"},children:["Not Found"]}},getParams:function(){if(!location.search)return{};for(var t,a={},e=location.search.substring(1).split("&"),n=0;n<e.length;n++)a[(t=e[n].split("="))[0]]=t[1];return a}};
//# sourceMappingURL=index.js.map

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

var t=!1,a=!1,e=!0;function n(n){var r=n.path,o=n.routes,h=n.key;void 0===h&&(h="location");var i=n.set;t||(t=!0,window.onpopstate=function(t){var e;a=!0;var n=t.target.location;i(((e={})[h]=n.pathname+n.search+n.hash,e))}),r&&r!==location.pathname||(r=location.pathname+location.search+location.hash);var c=document.createElement("a");c.href=location.origin+r;var s,p=c.pathname+c.search+c.hash;return o=o.find(function(t){return"string"==typeof t.path&&(t.path.match(/404/)&&(s=t),t.path=new RegExp("^"+t.path+"$","i")),c.pathname.match(t.path)}),a?a=!1:e?e=!1:history.pushState({},null,p),"object"==typeof o&&o.render?o.render():s?s.render():{element:"div",attributes:{class:"not-found"},children:["Not Found"]}}function r(){if(!location.search)return{};for(var t,a={},e=location.search.substring(1).split("&"),n=0;n<e.length;n++)a[(t=e[n].split("="))[0]]=t[1];return a}export default{Router:n,getParams:r};export{n as Router,r as getParams};
var t,a=!1,e=!1,n=!0;function r(r){var o=r.path,h=r.routes,i=r.key;void 0===i&&(i="location");var c=r.set;a||(a=!0,window.onpopstate=function(t){var a;e=!0;var n=t.target.location;c(((a={})[i]=n.pathname+n.search+n.hash,a))}),o&&o!==location.pathname||(o=location.pathname+location.search+location.hash);var s=document.createElement("a");s.href=location.origin+o;var p,l=s.pathname+s.search+s.hash;return h=h.find(function(t){return"string"==typeof t.path&&(t.path.match(/^404$/)&&(p=t),t.path=new RegExp("^"+t.path+"$","i")),s.pathname.match(t.path)}),e?e=!1:n?n=!1:t!==l&&history.pushState({},null,l),t=l,"object"==typeof h&&h.render?h.render():p?p.render():{element:"div",attributes:{class:"not-found"},children:["Not Found"]}}function o(){if(!location.search)return{};for(var t,a={},e=location.search.substring(1).split("&"),n=0;n<e.length;n++)a[(t=e[n].split("="))[0]]=t[1];return a}export default{Router:r,getParams:o};export{r as Router,o as getParams};
//# sourceMappingURL=index.m.js.map

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.literaljsRouter=e()}(this,function(){var t=!1,e=!1,n=!0;return{Router:function(a){var o=a.path,r=a.routes,i=a.key;void 0===i&&(i="location");var h=a.set;t||(t=!0,window.onpopstate=function(t){var n;e=!0;var a=t.target.location;h(((n={})[i]=a.pathname+a.search+a.hash,n))}),o&&o!==location.pathname||(o=location.pathname+location.search+location.hash);var c=document.createElement("a");c.href=location.origin+o;var s,u=c.pathname+c.search+c.hash;return r=r.find(function(t){return"string"==typeof t.path&&(t.path.match(/404/)&&(s=t),t.path=new RegExp("^"+t.path+"$","i")),c.pathname.match(t.path)}),e?e=!1:n?n=!1:history.pushState({},null,u),"object"==typeof r&&r.render?r.render():s?s.render():{element:"div",attributes:{class:"not-found"},children:["Not Found"]}},getParams:function(){if(!location.search)return{};for(var t,e={},n=location.search.substring(1).split("&"),a=0;a<n.length;a++)e[(t=n[a].split("="))[0]]=t[1];return e}}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.literaljsRouter=e()}(this,function(){var t,e=!1,n=!1,a=!0;return{Router:function(o){var r=o.path,i=o.routes,h=o.key;void 0===h&&(h="location");var c=o.set;e||(e=!0,window.onpopstate=function(t){var e;n=!0;var a=t.target.location;c(((e={})[h]=a.pathname+a.search+a.hash,e))}),r&&r!==location.pathname||(r=location.pathname+location.search+location.hash);var s=document.createElement("a");s.href=location.origin+r;var u,p=s.pathname+s.search+s.hash;return i=i.find(function(t){return"string"==typeof t.path&&(t.path.match(/^404$/)&&(u=t),t.path=new RegExp("^"+t.path+"$","i")),s.pathname.match(t.path)}),n?n=!1:a?a=!1:t!==p&&history.pushState({},null,p),t=p,"object"==typeof i&&i.render?i.render():u?u.render():{element:"div",attributes:{class:"not-found"},children:["Not Found"]}},getParams:function(){if(!location.search)return{};for(var t,e={},n=location.search.substring(1).split("&"),a=0;a<n.length;a++)e[(t=n[a].split("="))[0]]=t[1];return e}}});
//# sourceMappingURL=index.umd.js.map
{
"name": "literaljs-router",
"version": "0.0.5",
"version": "0.0.6",
"description": "A router built to work with LiteralJS.",

@@ -9,3 +9,3 @@ "main": "build/index.js",

"scripts": {
"rebuild": "sudo rm -rf build/ && yarn build",
"rebuild": "sudo rm -rf build/ && rm -rf yarn.lock && yarn build",
"build": "microbundle",

@@ -12,0 +12,0 @@ "prepare": "npm run build",

@@ -12,9 +12,9 @@ <p align="center">

Recent 0.0.5 microbundle:
Recent 0.0.6 microbundle:
```js
$ microbundle
Build output to build:
537 B: index.js
554 B: index.m.js
598 B: index.umd.js
547 B: index.js
566 B: index.m.js
608 B: index.umd.js
```

@@ -1,10 +0,11 @@

let historyListenerAdded = false;
let popstateTriggered = false;
let initialRender = true;
let HistoryListenerAdded = false;
let PopstateTriggered = false;
let InitialRender = true;
let LastLocation;
export function Router({ path, routes, key = 'location', set }) {
if (!historyListenerAdded) {
historyListenerAdded = true;
if (!HistoryListenerAdded) {
HistoryListenerAdded = true;
window.onpopstate = function(e) {
popstateTriggered = true;
PopstateTriggered = true;
const location = e.target.location;

@@ -28,3 +29,4 @@ set({ [key]: location.pathname + location.search + location.hash });

if (typeof route.path === 'string') {
if (route.path.match(/404/)) {
if (route.path.match(/^404$/)) {
// Find the 404 component
notFound = route;

@@ -40,8 +42,8 @@ }

// Determines If New URL Should Be Added To History
if (popstateTriggered) {
popstateTriggered = false;
if (PopstateTriggered) {
PopstateTriggered = false;
} else {
if (initialRender) {
initialRender = false;
} else {
if (InitialRender) {
InitialRender = false;
} else if (LastLocation !== incomingPath) {
history.pushState({}, null, incomingPath);

@@ -51,2 +53,4 @@ }

LastLocation = incomingPath;
// Render Correct Page

@@ -53,0 +57,0 @@ if (typeof routes === 'object' && routes.render) {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc