oembed-spec 1.3.30 → 1.3.33
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.
- package/README.md +2 -2
- package/package.json +20 -23
- package/scripts/{postinstall.js → fetch-providers.js} +15 -7
- package/scripts/providers.js +11 -0
- package/src/find-provider.js +4 -8
- package/src/providers.json +2393 -797
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
## Features
|
|
15
15
|
|
|
16
|
-
- Always on sync with [oEmbed providers](https://oembed.com/providers.json) (
|
|
16
|
+
- Always on sync with [oEmbed providers](https://oembed.com/providers.json) (updated weekly via GitHub Actions).
|
|
17
17
|
- Handle http/https & www/non-www URLs variations.
|
|
18
18
|
- Ability to pass extra oEmbed parameters.
|
|
19
19
|
- Built for speed (see [benchmarks](benchmarks/README.md)).
|
|
@@ -86,4 +86,4 @@ Standalone method for fetching an specific provider.
|
|
|
86
86
|
**oembed-spec** © [microlink.io](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/oembed-spec/blob/master/LICENSE) License.<br>
|
|
87
87
|
Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/microlinkhq/oembed-spec/contributors).
|
|
88
88
|
|
|
89
|
-
> [microlink.io](https://microlink.io) · GitHub [microlink.io](https://github.com/microlinkhq) ·
|
|
89
|
+
> [microlink.io](https://microlink.io) · GitHub [microlink.io](https://github.com/microlinkhq) · X [@microlinkhq](https://x.com/microlinkhq)
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oembed-spec",
|
|
3
3
|
"description": "A parser for oEmbed specification",
|
|
4
|
-
"homepage": "https://
|
|
5
|
-
"version": "1.3.
|
|
4
|
+
"homepage": "https://github.com/microlinkhq/oembed-spec",
|
|
5
|
+
"version": "1.3.33",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -37,11 +37,12 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"got": "~11.8.6",
|
|
40
|
-
"tldts": "~
|
|
40
|
+
"tldts": "~7.0.7"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@commitlint/cli": "latest",
|
|
44
44
|
"@commitlint/config-conventional": "latest",
|
|
45
|
+
"@ksmithut/prettier-standard": "latest",
|
|
45
46
|
"@microlink/demo-links": "latest",
|
|
46
47
|
"ava": "latest",
|
|
47
48
|
"benchmark": "latest",
|
|
@@ -49,16 +50,13 @@
|
|
|
49
50
|
"c8": "latest",
|
|
50
51
|
"chalk": "latest",
|
|
51
52
|
"ci-publish": "latest",
|
|
52
|
-
"conventional-github-releaser": "latest",
|
|
53
53
|
"finepack": "latest",
|
|
54
54
|
"git-authors-cli": "latest",
|
|
55
|
+
"github-generate-release": "latest",
|
|
55
56
|
"nano-staged": "latest",
|
|
56
|
-
"npm-check-updates": "latest",
|
|
57
57
|
"oembed-parser": "latest",
|
|
58
|
-
"prettier-standard": "latest",
|
|
59
58
|
"simple-git-hooks": "latest",
|
|
60
59
|
"standard": "latest",
|
|
61
|
-
"standard-markdown": "latest",
|
|
62
60
|
"standard-version": "latest"
|
|
63
61
|
},
|
|
64
62
|
"engines": {
|
|
@@ -71,18 +69,14 @@
|
|
|
71
69
|
"scripts": {
|
|
72
70
|
"benchmark": "node ./benchmarks/benchmark.js",
|
|
73
71
|
"clean": "rm -rf node_modules",
|
|
74
|
-
"contributors": "(npx git-authors-cli && npx finepack
|
|
75
|
-
"lint": "standard
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"prerelease": "npm run update:check",
|
|
79
|
-
"pretest": "npm run lint",
|
|
72
|
+
"contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
73
|
+
"lint": "standard",
|
|
74
|
+
"postrelease": "pnpm release:tags && pnpm release:github && (ci-publish || npm publish --access=public)",
|
|
75
|
+
"pretest": "pnpm lint",
|
|
80
76
|
"release": "standard-version -a",
|
|
81
|
-
"release:github": "
|
|
77
|
+
"release:github": "github-generate-release",
|
|
82
78
|
"release:tags": "git push --follow-tags origin HEAD:master",
|
|
83
|
-
"test": "c8 ava"
|
|
84
|
-
"update": "ncu -u",
|
|
85
|
-
"update:check": "ncu -- --error-level 2"
|
|
79
|
+
"test": "c8 ava"
|
|
86
80
|
},
|
|
87
81
|
"license": "MIT",
|
|
88
82
|
"ava": {
|
|
@@ -94,17 +88,20 @@
|
|
|
94
88
|
"commitlint": {
|
|
95
89
|
"extends": [
|
|
96
90
|
"@commitlint/config-conventional"
|
|
97
|
-
]
|
|
91
|
+
],
|
|
92
|
+
"rules": {
|
|
93
|
+
"body-max-line-length": [
|
|
94
|
+
0
|
|
95
|
+
]
|
|
96
|
+
}
|
|
98
97
|
},
|
|
99
98
|
"nano-staged": {
|
|
100
99
|
"*.js": [
|
|
101
|
-
"prettier-standard"
|
|
102
|
-
|
|
103
|
-
"*.md": [
|
|
104
|
-
"standard-markdown"
|
|
100
|
+
"prettier-standard",
|
|
101
|
+
"standard --fix"
|
|
105
102
|
],
|
|
106
103
|
"package.json": [
|
|
107
|
-
"finepack
|
|
104
|
+
"finepack"
|
|
108
105
|
]
|
|
109
106
|
},
|
|
110
107
|
"simple-git-hooks": {
|
|
@@ -117,11 +117,19 @@ function buildIndex (providers) {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
)
|
|
120
|
+
async function main () {
|
|
121
|
+
const json = await fetch(PROVIDERS_URL)
|
|
122
|
+
const providers = normalizeProviders(json)
|
|
123
|
+
const data = buildIndex(providers)
|
|
124
|
+
await writeFile(
|
|
125
|
+
path.resolve(__dirname, '../src/providers.json'),
|
|
126
|
+
JSON.stringify(data, null, 2)
|
|
126
127
|
)
|
|
127
|
-
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
main()
|
|
131
|
+
.then(() => process.exit(0))
|
|
132
|
+
.catch(error => {
|
|
133
|
+
console.error(error)
|
|
134
|
+
process.exit(1)
|
|
135
|
+
})
|
package/src/find-provider.js
CHANGED
|
@@ -50,19 +50,15 @@ const matchSchemes = (url, schemes) => {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const matchProvider = (url, provider) => {
|
|
53
|
-
const {
|
|
54
|
-
|
|
55
|
-
domainWithoutSuffixOfOembedUrl,
|
|
56
|
-
domainWithoutSuffixOfUrl
|
|
57
|
-
} = provider
|
|
53
|
+
const { schemes, domainWithoutSuffixOfOembedUrl, domainWithoutSuffixOfUrl } =
|
|
54
|
+
provider
|
|
58
55
|
|
|
59
56
|
if (schemes.length !== 0) {
|
|
60
57
|
return matchSchemes(url, schemes) === true ? provider : undefined
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
// Since the URL doesn't have an scheme to match, try to match over oEmbed/url
|
|
64
|
-
// domain. These are pre-computed
|
|
65
|
-
// is needed.
|
|
61
|
+
// domain. These are pre-computed so that no redundant work is needed.
|
|
66
62
|
const domain = getDomainWithoutSuffix(url)
|
|
67
63
|
if (
|
|
68
64
|
domain !== null &&
|
|
@@ -96,7 +92,7 @@ module.exports = url => {
|
|
|
96
92
|
// work is needed. In case of a match, we usually have a list of one or two
|
|
97
93
|
// candidates, which is very quick to match against.
|
|
98
94
|
//
|
|
99
|
-
// For more details about `index`, see documentation in `scripts/
|
|
95
|
+
// For more details about `index`, see documentation in `scripts/fetch-providers.js`.
|
|
100
96
|
const indicesOfCandidates = new Set()
|
|
101
97
|
for (const token of tokenize(baseUrl)) {
|
|
102
98
|
const providersForToken = index[token]
|