@zambezi/address
Advanced tools
Comparing version 3.0.4 to 3.0.5
@@ -55,3 +55,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -77,5 +77,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -344,17 +344,17 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 2 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_2__; | ||
/***/ }, | ||
/***/ }), | ||
/* 3 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_3__; | ||
/***/ }, | ||
/***/ }), | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -406,5 +406,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 5 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -438,5 +438,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -501,5 +501,5 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(2) ], __WEBPACK_AMD_DEFINE_RESULT__ = function(_) { | ||
/***/ }, | ||
/***/ }), | ||
/* 7 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -519,5 +519,5 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { | ||
/***/ }, | ||
/***/ }), | ||
/* 8 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -538,5 +538,5 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { | ||
/***/ }, | ||
/***/ }), | ||
/* 9 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -551,5 +551,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 10 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -567,3 +567,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
var currentResource = web.find(currentUri) | ||
, currentMetadata = repairResource(currentResource).metadata | ||
, requestedResource = web.find(requestedUri) | ||
, requestedMetadata = repairResource(requestedResource).metadata | ||
@@ -573,5 +575,5 @@ if(!currentResource || !requestedResource) return requestedUri | ||
var composedParams | ||
, redirect = currentResource.redirects[requestedResource.path] | ||
, composes = _.contains(currentResource.composes, requestedResource.path) | ||
, rewritePath = redirect || currentResource.path | ||
, redirect = currentMetadata.redirects[requestedMetadata.path] | ||
, composes = _.contains(currentMetadata.composes, requestedMetadata.path) | ||
, rewritePath = redirect || currentMetadata.path | ||
, shouldRewrite = redirect || composes | ||
@@ -590,2 +592,12 @@ | ||
// Because of the lack of documentation, there are uses of address where a set of customisation have been made: | ||
// + `web.find` is overridden. | ||
// + metadata properties is stored on the route resource itself, rather than on `resource.metadata`. | ||
// | ||
// In a future release we may want to deprecate or remove this behaviour. | ||
// Further details can be found: https://github.com/zambezi/address/issues/59 | ||
function repairResource(resource) { | ||
return _.extend({ metadata: resource }, resource) | ||
} | ||
function rewrite(web, path, params) { | ||
@@ -618,11 +630,11 @@ var alreadyInterpolated = _.chain(rhumb._parse(path)) | ||
/***/ }, | ||
/***/ }), | ||
/* 11 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_11__; | ||
/***/ }, | ||
/***/ }), | ||
/* 12 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -751,5 +763,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 13 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -779,5 +791,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 14 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -815,5 +827,15 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
resource = web.find(uri) | ||
return resource ? resource.path : undefined | ||
return resource ? repairResource(resource).metadata.path : undefined | ||
} | ||
// Because of the lack of documentation, there are uses of address where a set of customisation have been made: | ||
// + `web.find` is overridden. | ||
// + metadata properties is stored on the route resource itself, rather than on `resource.metadata`. | ||
// | ||
// In a future release we may want to deprecate or remove this behaviour. | ||
// Further details can be found: https://github.com/zambezi/address/issues/59 | ||
function repairResource(resource) { | ||
return _.extend({ metadata: resource }, resource) | ||
} | ||
function resourceWillChange(req, res, node) { | ||
@@ -832,5 +854,5 @@ var newPath = findPath(req.web, getCurrentUri(req, res)) | ||
/***/ }, | ||
/***/ }), | ||
/* 15 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -849,5 +871,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 16 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -867,5 +889,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 17 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -883,11 +905,11 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { | ||
/***/ }, | ||
/***/ }), | ||
/* 18 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_18__; | ||
/***/ }, | ||
/***/ }), | ||
/* 19 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -941,5 +963,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) 2010-2016, Michael Bostock | ||
/***/ }, | ||
/***/ }), | ||
/* 20 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1042,5 +1064,12 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
if (!a) return // Ignore non-anchor clicks | ||
if (!!a.target) return // Ignore anchors with specified targets | ||
if (!isSameOrigin(a, location)) return // Ignore links to different origins | ||
if ( !a // non-anchor clicks | ||
|| !!a.target // anchors with specified targets | ||
|| a.hasAttribute('download') // anchors with download attribute | ||
|| !isSameOrigin(a, location) // links to different origins | ||
) { | ||
/* If any of the above conditions are true, we ignore the click and | ||
* let the browser deal with the navigation as it sees fit | ||
*/ | ||
return | ||
} | ||
@@ -1051,4 +1080,5 @@ var path | ||
path = rebase(a.hash.slice(1)) | ||
} else if (a.hash) { | ||
return // Ignore links with a non-path hash | ||
} else if (a.hash || a.href.slice(location.href.length) === '#') { | ||
// Ignore links with a non-path hash, and empty hashes (e.g.: `<a href="#"></a>`) | ||
return | ||
} else { | ||
@@ -1138,5 +1168,5 @@ path = rebase(fullPath(a)) | ||
/***/ }, | ||
/***/ }), | ||
/* 21 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1191,5 +1221,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function() { | ||
/***/ }, | ||
/***/ }), | ||
/* 22 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1240,5 +1270,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 23 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1258,5 +1288,5 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { | ||
/***/ }, | ||
/***/ }), | ||
/* 24 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1272,5 +1302,5 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(1) | ||
/***/ }, | ||
/***/ }), | ||
/* 25 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1284,5 +1314,5 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(3) | ||
/***/ }, | ||
/***/ }), | ||
/* 26 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1302,5 +1332,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 27 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1317,5 +1347,5 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { | ||
/***/ }, | ||
/***/ }), | ||
/* 28 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1346,5 +1376,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 29 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1402,5 +1432,5 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) { | ||
/***/ }, | ||
/***/ }), | ||
/* 30 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1454,3 +1484,3 @@ var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) { | ||
/***/ } | ||
/***/ }) | ||
/******/ ]) | ||
@@ -1457,0 +1487,0 @@ }); |
{ | ||
"name": "@zambezi/address", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "API for nap resources", | ||
@@ -5,0 +5,0 @@ "main": "lib/address.js", |
@@ -11,2 +11,50 @@ # Address | ||
## Installation | ||
Address is available as the `@zambezi/address` package on [npm](https://www.npmjs.com/): | ||
$ npm install --save @zambezi/address | ||
Then using the module handler of your choice, you can use the following modules for requesting an addressable resource: | ||
```javascript | ||
// using ES6 modules | ||
import { address } from '@zambezi/address' | ||
// using AMD modules | ||
define([ | ||
'@zambezi/address/lib/address' | ||
], function(address) { | ||
// ... | ||
}) | ||
``` | ||
To create a resource, you should be importing the following: | ||
```javascript | ||
// using ES6 modules | ||
import { error, ok } from '@zambezi/address' | ||
export function myResource(req, res) { | ||
// ... | ||
} | ||
// using AMD modules | ||
define([ | ||
'@zambezi/address/lib/ok' | ||
, '@zambezi/address/lib/error' | ||
], function(ok, error) { | ||
return function myResource(req, res) { | ||
// ... | ||
} | ||
}) | ||
``` | ||
## API docs | ||
[Read them here](docs/API.md) | ||
## Usage | ||
@@ -13,0 +61,0 @@ |
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
109102
1164
526