Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
1.2.2: better test for domain matching for providers ...
Browse files Browse the repository at this point in the history
  • Loading branch information
mrose17 committed Nov 10, 2017
1 parent e91f0c2 commit dc8f2b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions getMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const jimp = require('jimp')
const metascraper = require('metascraper')
const NodeCache = require('node-cache')
const pcc = require('parse-cache-control')
const tldjs = require('tldjs')
const underscore = require('underscore')

const getPublisherFromMediaProps = (mediaProps, options, callback) => {
Expand Down Expand Up @@ -36,7 +37,7 @@ const mappers = {
}

const getPublisherFromMediaURL = (mediaURL, options, callback) => {
let providers
let parts, providers

if (typeof options === 'function') {
callback = options
Expand All @@ -52,7 +53,10 @@ const getPublisherFromMediaURL = (mediaURL, options, callback) => {
providers = underscore.filter(options.ruleset, (rule) => {
const schemes = rule.schemes

if (!schemes.length) return (mediaURL.indexOf(rule.domain) !== -1)
if (!schemes.length) {
parts = url.parse(mediaURL)
return ((parts) && (tldjs.getDomain(parts.hostname) === rule.domain))
}

for (let scheme in schemes) if (mediaURL.match(new RegExp(scheme.replace(/\*/g, '(.*)'), 'i'))) return true
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bat-publisher",
"version": "1.2.1",
"version": "1.2.2",
"description": "Routines to identify publishers for the BAT.",
"main": "index.js",
"scripts": {
Expand Down

1 comment on commit dc8f2b6

@diracdeltas
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Please sign in to comment.