From f43496ccc1096f8727ef0fd36403b9bc1ed66a3e Mon Sep 17 00:00:00 2001 From: Daniel Coulbourne Date: Sat, 21 Apr 2018 05:07:37 -0400 Subject: [PATCH] Fix a few missed Ziggy references. --- dist/js/route.js | 4 ++-- dist/js/route.min.js | 2 +- src/js/route.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/js/route.js b/dist/js/route.js index ff5116ac..9ac5584a 100644 --- a/dist/js/route.js +++ b/dist/js/route.js @@ -162,7 +162,7 @@ var Router = function (_String) { return this.template.replace(/{([^}]+)}/gi, function (tag, i) { var keyName = tag.replace(/\{|\}/gi, '').replace(/\?$/, ''), key = _this2.numericParamIndices ? paramsArrayKey : keyName, - defaultParameter = Ziggy.defaultParameters[keyName]; + defaultParameter = _this2.ziggy.defaultParameters[keyName]; if (defaultParameter && needDefaultParams) { if (_this2.numericParamIndices) { @@ -219,7 +219,7 @@ var Router = function (_String) { value: function current() { var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - var routeNames = Object.keys(Ziggy.namedRoutes); + var routeNames = Object.keys(this.ziggy.namedRoutes); var currentRoute = routeNames.filter(function (name) { return new Router(name).matchUrl(); diff --git a/dist/js/route.min.js b/dist/js/route.min.js index 3fd12a52..0c3f1034 100644 --- a/dist/js/route.min.js +++ b/dist/js/route.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("route",[],t):"object"==typeof exports?exports.route=t():e.route=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t,r,n){return new f(e,t,r,n)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a;var u=r(1),s=Object.assign||function(e){for(var t=1;t3&&void 0!==arguments[3]?arguments[3]:null;n(this,t);var s=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return s.name=e,s.absolute=i,s.ziggy=a||Ziggy,s.template=s.name?new u.a(e,i,s.ziggy).construct():"",s.urlParams=s.normalizeParams(r),s.queryParams=s.normalizeParams(r),s}return i(t,e),l(t,[{key:"normalizeParams",value:function(e){return void 0===e?{}:(e="object"!==(void 0===e?"undefined":c(e))?[e]:e,e.hasOwnProperty("id")&&-1==this.template.indexOf("{id}")&&(e=[e.id]),this.numericParamIndices=Array.isArray(e),s({},e))}},{key:"with",value:function(e){return this.urlParams=this.normalizeParams(e),this}},{key:"withQuery",value:function(e){return s(this.queryParams,e),this}},{key:"hydrateUrl",value:function(){var e=this,t=this.urlParams,r=0,n=this.template.match(/{([^}]+)}/gi),o=!1;return n&&n.length!=Object.keys(t).length&&(o=!0),this.template.replace(/{([^}]+)}/gi,function(n,i){var a=n.replace(/\{|\}/gi,"").replace(/\?$/,""),u=e.numericParamIndices?r:a,s=Ziggy.defaultParameters[a];if(s&&o&&(e.numericParamIndices?(t=Object.values(t),t.splice(u,0,s)):t[u]=s),r++,void 0!==t[u])return delete e.queryParams[u],t[u].id||encodeURIComponent(t[u]);if(-1===n.indexOf("?"))throw new Error("Ziggy Error: '"+a+"' key is required for route '"+e.name+"'");return""})}},{key:"matchUrl",value:function(){var e=(this.urlParams,window.location.hostname+(window.location.port?":"+window.location.port:"")+window.location.pathname),t=this.template.replace(/(\{[^\}]*\})/gi,"[^/?]+").split("://")[1],r=e.replace(/\/?$/,"/");return new RegExp("^"+t+"/$").test(r)}},{key:"constructQuery",value:function(){if(0===Object.keys(this.queryParams).length)return"";var e="?";return Object.keys(this.queryParams).forEach(function(t,r){this.queryParams[t]&&(e=0===r?e:e+"&",e+=t+"="+encodeURIComponent(this.queryParams[t]))}.bind(this)),e}},{key:"current",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=Object.keys(Ziggy.namedRoutes),n=r.filter(function(e){return new t(e).matchUrl()})[0];return e?e==n:n}},{key:"parse",value:function(){this.return=this.hydrateUrl()+this.constructQuery()}},{key:"url",value:function(){return this.parse(),this.return}},{key:"toString",value:function(){return this.url()}},{key:"valueOf",value:function(){return this.url()}}]),t}(String)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r3&&void 0!==arguments[3]?arguments[3]:null;n(this,t);var s=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return s.name=e,s.absolute=i,s.ziggy=a||Ziggy,s.template=s.name?new u.a(e,i,s.ziggy).construct():"",s.urlParams=s.normalizeParams(r),s.queryParams=s.normalizeParams(r),s}return i(t,e),l(t,[{key:"normalizeParams",value:function(e){return void 0===e?{}:(e="object"!==(void 0===e?"undefined":c(e))?[e]:e,e.hasOwnProperty("id")&&-1==this.template.indexOf("{id}")&&(e=[e.id]),this.numericParamIndices=Array.isArray(e),s({},e))}},{key:"with",value:function(e){return this.urlParams=this.normalizeParams(e),this}},{key:"withQuery",value:function(e){return s(this.queryParams,e),this}},{key:"hydrateUrl",value:function(){var e=this,t=this.urlParams,r=0,n=this.template.match(/{([^}]+)}/gi),o=!1;return n&&n.length!=Object.keys(t).length&&(o=!0),this.template.replace(/{([^}]+)}/gi,function(n,i){var a=n.replace(/\{|\}/gi,"").replace(/\?$/,""),u=e.numericParamIndices?r:a,s=e.ziggy.defaultParameters[a];if(s&&o&&(e.numericParamIndices?(t=Object.values(t),t.splice(u,0,s)):t[u]=s),r++,void 0!==t[u])return delete e.queryParams[u],t[u].id||encodeURIComponent(t[u]);if(-1===n.indexOf("?"))throw new Error("Ziggy Error: '"+a+"' key is required for route '"+e.name+"'");return""})}},{key:"matchUrl",value:function(){var e=(this.urlParams,window.location.hostname+(window.location.port?":"+window.location.port:"")+window.location.pathname),t=this.template.replace(/(\{[^\}]*\})/gi,"[^/?]+").split("://")[1],r=e.replace(/\/?$/,"/");return new RegExp("^"+t+"/$").test(r)}},{key:"constructQuery",value:function(){if(0===Object.keys(this.queryParams).length)return"";var e="?";return Object.keys(this.queryParams).forEach(function(t,r){this.queryParams[t]&&(e=0===r?e:e+"&",e+=t+"="+encodeURIComponent(this.queryParams[t]))}.bind(this)),e}},{key:"current",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=Object.keys(this.ziggy.namedRoutes),n=r.filter(function(e){return new t(e).matchUrl()})[0];return e?e==n:n}},{key:"parse",value:function(){this.return=this.hydrateUrl()+this.constructQuery()}},{key:"url",value:function(){return this.parse(),this.return}},{key:"toString",value:function(){return this.url()}},{key:"valueOf",value:function(){return this.url()}}]),t}(String)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var r=0;r { let keyName = tag.replace(/\{|\}/gi, '').replace(/\?$/, ''), key = this.numericParamIndices ? paramsArrayKey : keyName, - defaultParameter = Ziggy.defaultParameters[keyName]; + defaultParameter = this.ziggy.defaultParameters[keyName]; if (defaultParameter && needDefaultParams) { if (this.numericParamIndices) { @@ -111,7 +111,7 @@ class Router extends String { } current(name = null) { - let routeNames = Object.keys(Ziggy.namedRoutes); + let routeNames = Object.keys(this.ziggy.namedRoutes); let currentRoute = routeNames.filter(name => { return new Router(name).matchUrl();