Comparing version 7.2.0 to 8.0.0
25
index.js
'use strict'; | ||
const URL = require('url'); | ||
const {URL} = require('url'); | ||
const urlRegex = require('url-regex'); | ||
@@ -8,8 +8,5 @@ const normalizeUrl = require('normalize-url'); | ||
const ret = new Set(); | ||
const {searchParams} = (new URL(url)); | ||
// TODO: Use `(new URL(url)).searchParams` when targeting Node.js 8 | ||
const qs = URL.parse(url, true).query; | ||
for (const key of Object.keys(qs)) { | ||
const value = qs[key]; | ||
for (const [, value] of searchParams) { | ||
if (urlRegex({exact: true}).test(value)) { | ||
@@ -23,4 +20,6 @@ ret.add(value); | ||
module.exports = (text, options) => { | ||
options = options || {}; | ||
module.exports = (text, options = {}) => { | ||
if (typeof options.exclude !== 'undefined' && !Array.isArray(options.exclude)) { | ||
throw new TypeError('The `exclude` option must be an array'); | ||
} | ||
@@ -44,3 +43,13 @@ const ret = new Set(); | ||
for (const excludedItem of options.exclude || []) { | ||
for (const item of ret) { | ||
const regex = new RegExp(excludedItem); | ||
if (regex.test(item)) { | ||
ret.delete(item); | ||
break; | ||
} | ||
} | ||
} | ||
return ret; | ||
}; |
{ | ||
"name": "get-urls", | ||
"version": "7.2.0", | ||
"description": "Get all URLs in a string", | ||
"license": "MIT", | ||
"repository": "sindresorhus/get-urls", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"get", | ||
"urls", | ||
"url", | ||
"uri", | ||
"extract", | ||
"find", | ||
"scrape", | ||
"text", | ||
"string" | ||
], | ||
"dependencies": { | ||
"escape-goat": "^1.3.0", | ||
"normalize-url": "^2.0.0", | ||
"url-regex": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
"name": "get-urls", | ||
"version": "8.0.0", | ||
"description": "Get all URLs in a string", | ||
"license": "MIT", | ||
"repository": "sindresorhus/get-urls", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"get", | ||
"urls", | ||
"url", | ||
"uri", | ||
"extract", | ||
"find", | ||
"scrape", | ||
"text", | ||
"string" | ||
], | ||
"dependencies": { | ||
"normalize-url": "^3.3.0", | ||
"url-regex": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.25.0", | ||
"xo": "^0.23.0" | ||
} | ||
} |
@@ -48,3 +48,9 @@ # get-urls [![Build Status](https://travis-ci.org/sindresorhus/get-urls.svg?branch=master)](https://travis-ci.org/sindresorhus/get-urls) | ||
#### exclude | ||
Type: `string[]` | ||
Exclude URLs that match URLs in the given array. | ||
## Related | ||
@@ -51,0 +57,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
4087
2
42
65
+ Addednormalize-url@3.3.0(transitive)
- Removedescape-goat@^1.3.0
- Removeddecode-uri-component@0.2.2(transitive)
- Removedescape-goat@1.3.0(transitive)
- Removedis-plain-obj@1.1.0(transitive)
- Removednormalize-url@2.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedprepend-http@2.0.0(transitive)
- Removedquery-string@5.1.1(transitive)
- Removedsort-keys@2.0.0(transitive)
- Removedstrict-uri-encode@1.1.0(transitive)
Updatednormalize-url@^3.3.0