Compare commits

..

No commits in common. "fb5fc033b06a29267ea5c6283cdc4661f34f910d" and "bce1489b4b05514e8eb403bf3a5464495239331a" have entirely different histories.

5 changed files with 11 additions and 65 deletions

View file

@ -1,26 +1,5 @@
### [1.1.1](https://github.com/nzambello/link-previewer/compare/v1.1.0...v1.1.1) (2022-07-07)
## [1.1.0](https://github.com/nzambello/link-previewer/compare/v1.0.1...v1.1.0) (2022-07-07)
### Features
* handle links with no protocol from wikipedia ([9196390](https://github.com/nzambello/link-previewer/commit/9196390a186e50bf5d61415de995f23066258fe4))
### Maintenance
* add access public to publish config in package.json ([6cfe4df](https://github.com/nzambello/link-previewer/commit/6cfe4df5d5307daf7830f0fb5e2080e382f3aacd))
### [1.0.1](https://github.com/nzambello/link-previewer/compare/v1.0.0...v1.0.1) (2022-04-28)
### Maintenance
* update package name ([01e5871](https://github.com/nzambello/link-previewer/commit/01e58713f68f261e0fb1c0b0fd44243ab696dce2))
## 1.0.0 (2022-04-28) ## 1.0.0 (2022-04-28)

View file

@ -1,6 +1,6 @@
# link-previewer # link-previewer
[![npm version](https://img.shields.io/github/package-json/v/nzambello/link-previewer)](https://www.npmjs.com/package/@nzambello/link-previewer) [![npm version](https://img.shields.io/github/package-json/v/nzambello/link-previewer)](https://www.npmjs.com/package/link-previewer)
![Tests](https://github.com/nzambello/link-previewer/workflows/CI/badge.svg?branch=main) ![Tests](https://github.com/nzambello/link-previewer/workflows/CI/badge.svg?branch=main)
![TypeScript Support](https://img.shields.io/badge/TypeScript-Support-blue) ![TypeScript Support](https://img.shields.io/badge/TypeScript-Support-blue)
@ -9,18 +9,17 @@ Node util to retrieve preview info from a link (og tags, meta tags, images, vide
## Installation ## Installation
```bash ```bash
yarn add @nzambello/link-previewer yarn add link-previewer
``` ```
```bash ```bash
npm install @nzambello/link-previewer npm install link-previewer
``` ```
## Usage ## Usage
```ts ```ts
import type { ILinkPreviewInfo } from '@nzambello/link-previewer'; import getLinkPreview from 'link-previewer';
import getLinkPreview from '@nzambello/link-previewer';
getLinkPreview('https://www.youtube.com/watch?v=feH26j3rBz8').then(console.log); getLinkPreview('https://www.youtube.com/watch?v=feH26j3rBz8').then(console.log);
``` ```

View file

@ -1,12 +1,12 @@
{ {
"publishConfig": { "version": "1.0.0",
"access": "public"
},
"version": "1.1.1",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"files": ["dist", "src"], "files": [
"dist",
"src"
],
"engines": { "engines": {
"node": ">=12" "node": ">=12"
}, },
@ -32,7 +32,7 @@
"singleQuote": true, "singleQuote": true,
"trailingComma": "es5" "trailingComma": "es5"
}, },
"name": "@nzambello/link-previewer", "name": "link-previewer",
"author": "nzambello", "author": "nzambello",
"description": "Node util to retrieve preview info from a link (og tags, meta tags, images, videos)", "description": "Node util to retrieve preview info from a link (og tags, meta tags, images, videos)",
"repository": { "repository": {

View file

@ -31,7 +31,6 @@ const getMeta = ($: cheerio.Root, metaName: string) => {
const parseUrl = (url?: string, baseUrl?: string) => { const parseUrl = (url?: string, baseUrl?: string) => {
if (!url) return undefined; if (!url) return undefined;
if (!baseUrl || url.startsWith('http')) return url; if (!baseUrl || url.startsWith('http')) return url;
if (url.startsWith('//')) return `https:${url}`;
return `${baseUrl}${url}`; return `${baseUrl}${url}`;
}; };

View file

@ -3,7 +3,7 @@ import getLinkPreview, { ILinkPreviewInfo } from '../src';
const youtubeSample: ILinkPreviewInfo = { const youtubeSample: ILinkPreviewInfo = {
description: description:
'How much do we know about the impact of technologies we use everyday? How much the web industry is responsible for carbon emissions? Can we define an ethic d...', 'How much do we know about the impact of technologies we use everyday? How much the web industry is responsible for carbon emissions? Can we define an ethic d...',
favicon: 'https://www.youtube.com/s/desktop/97650662/img/favicon.ico', favicon: 'https://www.youtube.com/s/desktop/ce262d3b/img/favicon.ico',
image: 'https://i.ytimg.com/vi/feH26j3rBz8/maxresdefault.jpg', image: 'https://i.ytimg.com/vi/feH26j3rBz8/maxresdefault.jpg',
imageHeight: 720, imageHeight: 720,
imageWidth: 1280, imageWidth: 1280,
@ -35,30 +35,6 @@ const rawmaterialSample: ILinkPreviewInfo = {
videos: [], videos: [],
}; };
const wikipediaSample: ILinkPreviewInfo = {
description: undefined,
favicon: 'https://en.wikipedia.org/static/favicon/wikipedia.ico',
image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e2/Plone_5.2.png/1200px-Plone_5.2.png',
imageHeight: 1423,
imageWidth: 1200,
images: [
'https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Plone-logo.svg/121px-Plone-logo.svg.png',
'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e2/Plone_5.2.png/300px-Plone_5.2.png',
'https://upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/10px-OOjs_UI_icon_edit-ltr-progressive.svg.png',
'https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Free_and_open-source_software_logo_%282009%29.svg/28px-Free_and_open-source_software_logo_%282009%29.svg.png',
'https://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/30px-Commons-logo.svg.png',
'https://upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/10px-OOjs_UI_icon_edit-ltr-progressive.svg.png',
'https://en.wikipedia.org/static/images/footer/wikimedia-button.png',
'https://en.wikipedia.org/static/images/footer/poweredby_mediawiki_88x31.png',
],
mediaType: 'website',
siteName: undefined,
title: 'Plone (software) - Wikipedia',
video: undefined,
videos: [],
};
it('gets correct info for RawMaterial website', async () => { it('gets correct info for RawMaterial website', async () => {
const info = await getLinkPreview('https://rawmaterial.it/en'); const info = await getLinkPreview('https://rawmaterial.it/en');
expect(info).toEqual(rawmaterialSample); expect(info).toEqual(rawmaterialSample);
@ -70,10 +46,3 @@ it('gets correct info for YouTube video link', async () => {
); );
expect(info).toEqual(youtubeSample); expect(info).toEqual(youtubeSample);
}); });
it('gets correct info for Wikipedia url', async () => {
const info = await getLinkPreview(
'https://en.wikipedia.org/wiki/Plone_(software)'
);
expect(info).toEqual(wikipediaSample);
});