absolution
Advanced tools
Comparing version 1.0.0 to 1.0.2
10
index.js
@@ -13,3 +13,3 @@ var htmlparser = require('htmlparser2'); | ||
var selfClosingMap = {}; | ||
_.each(options.selfClosing, function(tag) { | ||
_.forEach(options.selfClosing, function(tag) { | ||
selfClosingMap[tag] = true; | ||
@@ -22,5 +22,4 @@ }); | ||
onopentag: function(name, attribs) { | ||
var changes = {}; | ||
_.each(options.urlAttributes, function(attr) { | ||
if (_.has(attribs, attr)) { | ||
_.forEach(options.urlAttributes, function(attr) { | ||
if (_.has(attribs, attr) && attribs[attr].trim()) { | ||
attribs[attr] = url.resolve(base, attribs[attr]); | ||
@@ -32,5 +31,4 @@ if (options.decorator) { | ||
}); | ||
_.extend(attribs, changes); | ||
result += '<' + name; | ||
_.each(attribs, function(value, a) { | ||
_.forEach(attribs, function(value, a) { | ||
result += ' ' + a; | ||
@@ -37,0 +35,0 @@ if (value.length) { |
{ | ||
"name": "absolution", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "absolution accepts HTML and a base URL, and returns HTML with absolute URLs. Great for generating valid RSS feeds.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha test/test.js" | ||
"test": "mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/punkave/absolution.git" | ||
"url": "https://github.com/apostrophecms/absolution.git" | ||
}, | ||
@@ -27,3 +27,3 @@ "keywords": [ | ||
], | ||
"author": "P'unk Avenue LLC", | ||
"author": "Apostrophe Technologies", | ||
"license": "MIT", | ||
@@ -33,4 +33,7 @@ "readmeFilename": "README.md", | ||
"htmlparser2": "~3.3.0", | ||
"lodash": "~2.0.0" | ||
"lodash": "~4.17.15" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^7.2.0" | ||
} | ||
} | ||
} |
@@ -15,11 +15,13 @@ # absolution | ||
npm install absolution | ||
`npm install absolution` | ||
var absolution = require('absolution'); | ||
```javascript | ||
var absolution = require('absolution'); | ||
var dirty = '<a href="/foo">Foo!</a>'; | ||
var clean = absolution(dirty, 'http://example.com'); | ||
var dirty = '<a href="/foo">Foo!</a>'; | ||
var clean = absolution(dirty, 'http://example.com'); | ||
// clean is now: | ||
// <a href="http://example.com/foo">Foo!</a> | ||
// clean is now: | ||
// <a href="http://example.com/foo">Foo!</a> | ||
``` | ||
@@ -30,10 +32,14 @@ Boom! | ||
var clean = absolution(dirty, 'http://example.com', { | ||
decorator: function(url) { | ||
return 'http://mycoolthing.com?url=' + encodeURIComponent(url); | ||
} | ||
}); | ||
```javascript | ||
var clean = absolution(dirty, 'http://example.com', { | ||
decorator: function(url) { | ||
return 'http://mycoolthing.com?url=' + encodeURIComponent(url); | ||
} | ||
}); | ||
``` | ||
## Changelog | ||
1.0.2: Updates to lodash v4 and mocha v7 for security vulnerability fixes. Also update package metadata. | ||
1.0.0: no new changes; declared stable as with the addition of the decorator option there's little left to do, and all tests are passing nicely. | ||
@@ -40,0 +46,0 @@ |
@@ -25,2 +25,7 @@ var assert = require("assert"); | ||
}); | ||
// Note that quotation marks are removed in the below test because all attributes are reconstructed | ||
// and there is no need for quotation marks without a value | ||
it('should keep empty url attributes empty', function() { | ||
assert.equal(absolution('<link rel="stylesheet" href="" />', 'http://localhost:8000/index.html'), '<link rel="stylesheet" href />'); | ||
}); | ||
// Finally the cool thing! | ||
@@ -44,2 +49,1 @@ it('should resolve relative URLs ("file" in same "folder")', function() { | ||
}); | ||
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
11682
107
59
1
6
1
+ Addedlodash@4.17.21(transitive)
- Removedlodash@2.0.0(transitive)
Updatedlodash@~4.17.15