@metascraper/helpers
Advanced tools
+19
| # metascraper-helpers | ||
| [](https://www.npmjs.com/package/metascraper-helpers) | ||
| [](https://david-dm.org/microlinkhq/metascraper?path=packages/metascraper-helpers) | ||
| > Collection of helper functions used by metascraper. | ||
| ## Install | ||
| ```bash | ||
| $ npm install @metascraper/helpers --save | ||
| ``` | ||
| ## License | ||
| **metascraper-helpers** © [microlink.io](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/metascraper-helpers/blob/master/LICENSE.md) License.<br> | ||
| Authored and maintained by microlink.io with help from [contributors](https://github.com/microlinkhq/metascraper-helpers/contributors). | ||
| > [microlink.io](https://microlink.io) · GitHub [@microlink.io](https://github.com/microlinkhq) · Twitter [@microlinkhq](https://twitter.com/microlinkhq) |
+14
-5
@@ -8,14 +8,23 @@ 'use strict' | ||
| const smartquotes = require('smartquotes') | ||
| const { flow, isNil } = require('lodash') | ||
| const toTitle = require('to-title-case') | ||
| const urlRegex = require('url-regex') | ||
| const { flow } = require('lodash') | ||
| const isUrl = value => urlRegex().test(value) | ||
| const isUrl = (url, {relative = true} = {}) => { | ||
| if (isNil(url)) return false | ||
| if (!relative) return urlRegex().test(url) | ||
| return isRelativeUrl(url) || urlRegex().test(url) | ||
| } | ||
| const normalizeUrl = url => sanetizeUrl(url, { stripWWW: false }) | ||
| const getAbsoluteUrl = (url, baseUrl) => | ||
| isRelativeUrl(url) ? resolveUrl(baseUrl, url) : url | ||
| const getAbsoluteUrl = (baseUrl, relativePath = '') => ( | ||
| isRelativeUrl(relativePath) | ||
| ? resolveUrl(baseUrl, relativePath) | ||
| : relativePath | ||
| ) | ||
| const getUrl = (url, baseUrl) => normalizeUrl(getAbsoluteUrl(url, baseUrl)) | ||
| const getUrl = (baseUrl, relativePath) => ( | ||
| normalizeUrl(getAbsoluteUrl(baseUrl, relativePath)) | ||
| ) | ||
@@ -22,0 +31,0 @@ const createTitle = flow([condenseWhitespace, smartquotes]) |
+1
-1
@@ -5,3 +5,3 @@ { | ||
| "homepage": "https://metascraper.js.org", | ||
| "version": "3.2.0", | ||
| "version": "3.3.0", | ||
| "main": "src/index.js", | ||
@@ -8,0 +8,0 @@ "author": { |
-12
| # Change Log | ||
| All notable changes to this project will be documented in this file. | ||
| See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
| <a name="3.2.0"></a> | ||
| # [3.2.0](https://github.com/microlinkhq/metascraper/tree/master/packages/metascraper-helpers/compare/v3.1.0...v3.2.0) (2017-12-19) | ||
| **Note:** Version bump only for package @metascraper/helpers |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
3031
35.74%35
34.62%0
-100%20
Infinity%