@metascraper/helpers
Advanced tools
Comparing version 3.2.0 to 3.3.0
19
index.js
@@ -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]) |
@@ -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": { |
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
0
20