Comparing version 1.0.1 to 1.1.0
@@ -0,1 +1,5 @@ | ||
# 1.1.0 - 2016-03-10 | ||
- Revert slugifying existing element IDs as this breaks dereferencing. Instead, we now produce a new link relation called `uri-fragment` with each element that is safe to use in a URL and is based on the element's ID. Note: going from a URI fragment to an element ID requires either a search through all element link relations or a pre-built mapping of URI fragments to elements. | ||
# 1.0.1 - 2016-03-09 | ||
@@ -2,0 +6,0 @@ |
@@ -14,3 +14,3 @@ // A module to forge IDs for Refract elements. | ||
_slug2['default'].defaults.modes.pretty.lower = true; | ||
_slug2['default'].defaults.mode = 'rfc3986'; | ||
@@ -31,2 +31,6 @@ var Abagnale = (function () { | ||
if (this.options.uriSeparator === undefined) { | ||
this.options.uriSeparator = '/'; | ||
} | ||
this.cache = {}; | ||
@@ -115,6 +119,6 @@ } | ||
if (refract.meta.id) { | ||
newPath = [(0, _slug2['default'])(refract.meta.id)]; | ||
newPath = [refract.meta.id]; | ||
} else if (path.length === 0 && refract.meta.classes && refract.meta.classes.length === 1) { | ||
// This is the first item, and it has a class name, so we use that. | ||
newPath = [(0, _slug2['default'])(refract.meta.classes[0])]; | ||
newPath = [refract.meta.classes[0]]; | ||
} | ||
@@ -144,2 +148,16 @@ } | ||
if (!refract.meta.links) { | ||
refract.meta.links = []; | ||
} | ||
refract.meta.links.push({ | ||
element: 'link', | ||
content: { | ||
relation: 'uri-fragment', | ||
href: refract.meta.id.split(this.options.separator).map(function (item) { | ||
return (0, _slug2['default'])(item); | ||
}).join(this.options.uriSeparator) | ||
} | ||
}); | ||
// Array like content containing elements? | ||
@@ -146,0 +164,0 @@ if (refract.content && refract.content.length && refract.content[0].element) { |
{ | ||
"name": "abagnale", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Forge unique IDs for Refract data structure elements", | ||
@@ -5,0 +5,0 @@ "main": "lib/abagnale.js", |
@@ -9,4 +9,6 @@ # Abagnale | ||
See the [test output](https://github.com/apiaryio/abagnale/tree/master/test/output) directory for examples of generated IDs. | ||
Along with unique IDs it also attempts to give each element a unique URI fragment that is safe to use in a URL and based on the element's unique ID. This can be found in a link relation called `uri-fragment`. | ||
See the [test output](https://github.com/apiaryio/abagnale/tree/master/test/output) directory for examples of generated IDs and URI fragments. | ||
It is named after [Frank Abagnale](https://en.wikipedia.org/wiki/Frank_Abagnale), one of the most notorious tricksters ever known. He forged several fake IDs, a pilots license with which he flew over a million miles, faked being a college professor, worked as a fake chief resident pediatrician, and worked in the Louisiana State Attorney General's office with a fake degree from Harvard before being caught. | ||
@@ -41,5 +43,6 @@ | ||
Name | Description | Default | ||
----------- | --------------------------------- | ------- | ||
`separator` | Character to denote path segments | `.` | ||
Name | Description | Default | ||
-------------- | -------------------------------------------------- | ------- | ||
`separator` | Character to denote path segments | `.` | ||
`uriSeparator` | Character to denote path segments in URI fragments | `/` | ||
@@ -46,0 +49,0 @@ ### Notable Missing Features |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
21639
172
88
1