Skip to content

Commit b195ed2

Browse files
authored
Merge pull request #189 from extractus/4.0.7
v4.0.7
2 parents 9f6c9d7 + ef37fc9 commit b195ed2

8 files changed

+1510
-1051
lines changed

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@
3131
"reset": "node reset"
3232
},
3333
"dependencies": {
34-
"cross-fetch": "^4.0.0",
35-
"linkedom": "^0.16.11"
34+
"cross-fetch": "^4.1.0",
35+
"linkedom": "^0.18.9"
3636
},
3737
"devDependencies": {
38-
"eslint": "^9.2.0",
39-
"globals": "^15.1.0",
40-
"https-proxy-agent": "^7.0.4",
38+
"@eslint/js": "^9.24.0",
39+
"eslint": "^9.24.0",
40+
"globals": "^16.0.0",
41+
"https-proxy-agent": "^7.0.6",
4142
"jest": "^29.7.0",
42-
"nock": "^13.5.4"
43+
"nock": "^14.0.3"
4344
},
4445
"keywords": [
4546
"oembed",

src/main.test.js

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const hasPhotoKeys = (o) => {
7272
})
7373
}
7474

75-
const hasInstagramKeys = (o) => {
75+
export const hasInstagramKeys = (o) => {
7676
return InstagramKeys.every((k) => {
7777
return hasProperty(o, k)
7878
})
@@ -138,34 +138,6 @@ describe('test if extract() with some popular providers', () => {
138138
},
139139
checkFn: hasRichKeys,
140140
},
141-
{
142-
input: {
143-
url: 'https://www.instagram.com/p/ic7kRDqOlt/',
144-
params: {
145-
access_token: '845078789498971|8ff3ab4ddd45b8f018b35c4fb7edac62',
146-
},
147-
file: './test-data/instagram_ic7kRDqOlt.json',
148-
},
149-
expected: {
150-
provider_name: 'Instagram',
151-
type: 'rich',
152-
},
153-
checkFn: hasInstagramKeys,
154-
},
155-
{
156-
input: {
157-
url: 'https://www.facebook.com/facebook/videos/10153231379946729/',
158-
params: {
159-
access_token: '845078789498971|8ff3ab4ddd45b8f018b35c4fb7edac62',
160-
},
161-
file: './test-data/facebook.json',
162-
},
163-
expected: {
164-
provider_name: 'Facebook',
165-
type: 'video',
166-
},
167-
checkFn: hasRichKeys,
168-
},
169141
{
170142
input: {
171143
url: 'https://flic.kr/p/2iYctUr',

src/utils/fetchEmbed.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ describe('test if fetchEmbed() works correctly', () => {
4646
type: 'rich',
4747
},
4848
},
49-
{
50-
input: {
51-
url: 'https://www.facebook.com/facebook/videos/10153231379946729/',
52-
params: {
53-
access_token: '845078789498971|8ff3ab4ddd45b8f018b35c4fb7edac62',
54-
},
55-
file: './test-data/facebook.json',
56-
},
57-
expected: {
58-
provider_name: 'Facebook',
59-
type: 'video',
60-
},
61-
},
49+
// {
50+
// input: {
51+
// url: 'https://www.facebook.com/facebook/videos/10153231379946729/',
52+
// params: {
53+
// access_token: '845078789498971|8ff3ab4ddd45b8f018b35c4fb7edac62',
54+
// },
55+
// file: './test-data/facebook.json',
56+
// },
57+
// expected: {
58+
// provider_name: 'Facebook',
59+
// type: 'video',
60+
// },
61+
// },
6262
{
6363
input: {
6464
url: 'http://farm4.static.flickr.com/3123/2341623661_7c99f48bbf_m.jpg',

src/utils/provider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const undotted = (scheme = '') => {
1717
}
1818

1919
const removeProtocol = (url) => {
20-
return url.replace('https://', '').replace('http://', '')
20+
return url.replace('https://', '//').replace('http://', '//')
2121
}
2222

2323
export const simplify = (providers = []) => {
@@ -43,7 +43,7 @@ const providersFromList = (providers = []) => {
4343
return providers.map((provider) => {
4444
const { e: endpoint, s: schemes } = provider
4545
return {
46-
endpoint: `https://${endpoint}`,
46+
endpoint: `https:${endpoint}`,
4747
schemes: schemes.map(toRegExp),
4848
}
4949
})

src/utils/provider.test.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,6 @@ import provider from './provider.js'
55

66
describe('test if provider.find() works correctly', () => {
77
const cases = [
8-
{
9-
url: 'https://www.facebook.com/video.php?v=999999999',
10-
fetchEndpoint: 'https://graph.facebook.com/v16.0/oembed_video',
11-
},
12-
{
13-
url: 'https://www.facebook.com/someone/photos/somephoto',
14-
fetchEndpoint: 'https://graph.facebook.com/v16.0/oembed_post',
15-
},
16-
{
17-
url: 'https://www.facebook.com/someone/page',
18-
fetchEndpoint: 'https://graph.facebook.com/v16.0/oembed_page',
19-
},
20-
{
21-
url: 'http://instagram.com/someone/p/somepage',
22-
fetchEndpoint: 'https://graph.facebook.com/v16.0/instagram_oembed',
23-
},
248
{
259
url: 'https://www.edumedia-sciences.com/en/media/558-heredity',
2610
fetchEndpoint: 'https://www.edumedia-sciences.com/oembed.json',
@@ -86,6 +70,6 @@ describe('test if provider set/get works correctly', () => {
8670
expect(provider.set(providerList)).toEqual(providerList.length)
8771
const newList = provider.get()
8872
expect(newList.length).toEqual(providerList.length)
89-
expect(newList[0].schemes[0]).toEqual(/store.alpha.com\/(.*)/i)
73+
expect(newList[0].schemes[0]).toEqual(/\/\/store.alpha.com\/(.*)/i)
9074
})
9175
})

0 commit comments

Comments
 (0)