metascraper-amazon 5.51.1 → 5.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/index.js +6 -3
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "metascraper-amazon",
3
3
  "description": "Metascraper integration with Amazon",
4
4
  "homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-amazon",
5
- "version": "5.51.1",
5
+ "version": "5.52.0",
6
6
  "types": "src/index.d.ts",
7
7
  "main": "src/index.js",
8
8
  "author": {
@@ -24,7 +24,7 @@
24
24
  "metascraper"
25
25
  ],
26
26
  "dependencies": {
27
- "@metascraper/helpers": "5.51.1"
27
+ "@metascraper/helpers": "5.52.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "ava": "8"
@@ -39,5 +39,5 @@
39
39
  "test": "NODE_PATH=.. TZ=UTC ava --timeout 15s"
40
40
  },
41
41
  "license": "MIT",
42
- "gitHead": "6059223e2c30ca9a4d5067dd265609a8ad74f47e"
42
+ "gitHead": "15039a21cdccb414f96ed9ef2687fecaac882597"
43
43
  }
package/src/index.js CHANGED
@@ -11,10 +11,13 @@ const {
11
11
  url
12
12
  } = require('@metascraper/helpers')
13
13
 
14
- const REGEX_AMAZON_URL =
15
- /https?:\/\/(.*amazon\..*\/.*|.*amzn\..*\/.*|.*a\.co\/.*)/i
14
+ const isAmazonDomain = domain => {
15
+ if (!domain) return false
16
+ if (domain === 'a.co') return true
17
+ return /^(?:amazon|amzn)\./.test(domain)
18
+ }
16
19
 
17
- const test = memoizeOne(url => REGEX_AMAZON_URL.test(url))
20
+ const test = memoizeOne(url => isAmazonDomain(parseUrl(url).domain))
18
21
 
19
22
  const SUFFIX_LANGUAGES = {
20
23
  ca: 'en',