Skip to content

Commit

Permalink
Merge pull request #148 from ndaidong/3.0.9
Browse files Browse the repository at this point in the history
3.0.9
  • Loading branch information
ndaidong authored Aug 19, 2022
2 parents af872d2 + b5efa39 commit 881c77e
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 290 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on: [push, pull_request]
jobs:
test:

runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
matrix:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ Extract oEmbed content from given URL.
![CodeQL](https://github.com/ndaidong/oembed-parser/workflows/CodeQL/badge.svg)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

[![Deploy](https://button.deta.dev/1/svg)](https://go.deta.dev/deploy?repo=https://github.com/ndaidong/oembed-parser-deta)

## Demo

- [Give it a try!](https://demos.pwshub.com/oembed-parser)
- [Example FaaS](https://extractor.pwshub.com/oembed/parse?url=https://www.instagram.com/tv/CVlR5GFqF68/&apikey=demo-TEyRycuuMCiGBiBocbLGSpagfj7gOF8AMyAWfEgP)
- [Example FaaS](https://oembed.deta.dev/?url=https://www.instagram.com/tv/CVlR5GFqF68/)


## Setup
Expand Down
6 changes: 3 additions & 3 deletions build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('Validate commonjs version output', () => {
const constent = readFileSync(cjsFile, 'utf8')
const lines = constent.split('\n')
test('Check if file meta contains package info', () => {
expect(lines[1].includes(`${pkg.name}@${pkg.version}`)).toBeTruthy()
expect(lines[1].includes(pkg.author)).toBeTruthy()
expect(lines[1].includes(pkg.license)).toBeTruthy()
expect(lines[0].includes(`${pkg.name}@${pkg.version}`)).toBeTruthy()
expect(lines[0].includes(pkg.author)).toBeTruthy()
expect(lines[0].includes(pkg.license)).toBeTruthy()
})
})
366 changes: 118 additions & 248 deletions dist/cjs/oembed-parser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "oembed-parser-cjs",
"version": "3.0.8",
"version": "3.0.9",
"main": "./oembed-parser.js"
}
18 changes: 17 additions & 1 deletion dist/cjs/providers.latest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// provider data, synchronized at 2022-07-28T14:44:04.385Z
// provider data, synchronized at 2022-08-19T11:28:55.403Z

/* eslint-disable */

Expand Down Expand Up @@ -3635,6 +3635,22 @@ export const providers = [
}
]
},
{
"provider_name": "Twinmotion",
"provider_url": "https://twinmotion.unrealengine.com",
"endpoints": [
{
"schemes": [
"https://twinmotion.unrealengine.com/presentation/*",
"https://twinmotion.unrealengine.com/panorama/*"
],
"url": "https://twinmotion.unrealengine.com/oembed",
"formats": [
"json"
]
}
]
},
{
"provider_name": "Twitter",
"provider_url": "http://www.twitter.com/",
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.0.8",
"version": "3.0.9",
"name": "oembed-parser",
"description": "Get oEmbed data from given URL.",
"homepage": "https://www.npmjs.com/package/oembed-parser",
Expand Down Expand Up @@ -28,16 +28,16 @@
},
"dependencies": {
"axios": "^0.27.2",
"bellajs": "^11.0.3",
"tldts": "^5.7.84"
"bellajs": "^11.0.4",
"tldts": "^5.7.89"
},
"standard": {
"ignore": [
"/dist"
]
},
"devDependencies": {
"esbuild": "^0.14.50",
"esbuild": "^0.15.5",
"jest": "^28.1.3",
"nock": "^13.2.9"
},
Expand Down
18 changes: 17 additions & 1 deletion src/utils/providers.latest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// provider data, synchronized at 2022-07-28T14:44:04.385Z
// provider data, synchronized at 2022-08-19T11:28:55.403Z

/* eslint-disable */

Expand Down Expand Up @@ -3635,6 +3635,22 @@ export const providers = [
}
]
},
{
"provider_name": "Twinmotion",
"provider_url": "https://twinmotion.unrealengine.com",
"endpoints": [
{
"schemes": [
"https://twinmotion.unrealengine.com/presentation/*",
"https://twinmotion.unrealengine.com/panorama/*"
],
"url": "https://twinmotion.unrealengine.com/oembed",
"formats": [
"json"
]
}
]
},
{
"provider_name": "Twitter",
"provider_url": "http://www.twitter.com/",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/providers.prev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// provider data, synchronized at 2022-07-24T14:03:37.993Z
// provider data, synchronized at 2022-07-28T14:44:04.385Z

/* eslint-disable */

Expand Down
14 changes: 0 additions & 14 deletions src/utils/retrieve.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,9 @@ import axios from 'axios'

import { getRequestOptions } from '../config.js'

const isValidContentType = (ctype) => {
return [
'application/json',
'application/javascript',
'text/javascript'
].some((item) => {
return ctype.includes(item)
})
}

export default async (url) => {
try {
const res = await axios.get(url, getRequestOptions())
const contentType = res.headers['content-type'] || ''
if (!isValidContentType(contentType)) {
throw new Error(`Invalid content type: "${contentType}"`)
}
return res.data
} catch (err) {
throw new Error(`${err.name}: ${err.message}`)
Expand Down
15 changes: 0 additions & 15 deletions src/utils/retrieve.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,6 @@ describe('test retrieve() method', () => {
nock.cleanAll()
})

test('test retrieve with unsupported content type', async () => {
const url = 'https://some.where/unsupported-content-type'
const { baseUrl, path } = parseUrl(url)
nock(baseUrl).get(path).reply(200, '', {
'Content-Type': 'abc/js'
})
expect(retrieve(url)).rejects.toThrow(new Error('Error: Invalid content type: "abc/js"'))
try {
await retrieve(url)
} catch (err) {
expect(err).toBeTruthy()
}
nock.cleanAll()
})

test('test retrieve with error 500', async () => {
const url = 'https://some.where/error/500'
const { baseUrl, path } = parseUrl(url)
Expand Down

0 comments on commit 881c77e

Please sign in to comment.