Comparing version 3.0.1 to 3.1.0
@@ -13,3 +13,3 @@ { | ||
"bugs": "https://github.com/ericnorris/striptags/issues", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"devDependencies": { | ||
@@ -16,0 +16,0 @@ "istanbul": "^0.4.5", |
# striptags [![Build Status](https://travis-ci.org/ericnorris/striptags.svg)](https://travis-ci.org/ericnorris/striptags) | ||
An implementation of PHP's [strip_tags](http://www.php.net/manual/en/function.strip-tags.php) in Node.js. | ||
**Note:** `v3+` targets ES6, and is therefore incompatible with the master branch of `uglifyjs`. You can either: | ||
- use `babili`, which supports ES6 | ||
- use the `harmony` branch of `uglifyjs` | ||
- stick with the [2.x.x](https://github.com/ericnorris/striptags/tree/v2.x.x) branch | ||
## Features | ||
@@ -5,0 +10,0 @@ - Fast |
@@ -5,2 +5,11 @@ 'use strict'; | ||
// minimal symbol polyfill for IE11 and others | ||
if (typeof Symbol !== 'function') { | ||
var Symbol = function(name) { | ||
return name; | ||
} | ||
Symbol.nonNative = true; | ||
} | ||
const STATE_PLAINTEXT = Symbol('plaintext'); | ||
@@ -40,4 +49,4 @@ const STATE_HTML = Symbol('html'); | ||
return { | ||
allowable_tags, | ||
tag_replacement, | ||
allowable_tags : allowable_tags, | ||
tag_replacement: tag_replacement, | ||
@@ -184,3 +193,3 @@ state : STATE_PLAINTEXT, | ||
function parse_allowable_tags(allowable_tags) { | ||
let tags_array = []; | ||
let tag_set = new Set(); | ||
@@ -190,12 +199,19 @@ if (typeof allowable_tags === 'string') { | ||
while ((match = ALLOWED_TAGS_REGEX.exec(allowable_tags)) !== null) { | ||
tags_array.push(match[1]); | ||
while ((match = ALLOWED_TAGS_REGEX.exec(allowable_tags))) { | ||
tag_set.add(match[1]); | ||
} | ||
} | ||
else if (typeof allowable_tags[Symbol.iterator] === 'function') { | ||
tags_array = allowable_tags; | ||
else if (!Symbol.nonNative && | ||
typeof allowable_tags[Symbol.iterator] === 'function') { | ||
tag_set = new Set(allowable_tags); | ||
} | ||
return new Set(tags_array); | ||
else if (typeof allowable_tags.forEach === 'function') { | ||
// IE11 compatible | ||
allowable_tags.forEach(tag_set.add, tag_set); | ||
} | ||
return tag_set; | ||
} | ||
@@ -202,0 +218,0 @@ |
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
16818
323
91