Skip to content

Commit

Permalink
chore: remove 'crypto-js' dep
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomontalbano committed May 15, 2024
1 parent b852076 commit 7d35b20
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
15 changes: 4 additions & 11 deletions netlify/functions/classes/Providers/Video.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import VideoProvider from '../VideoProvider.js';
import VideoRegEx from './VideoRegEx.js';

import CryptoJS from 'crypto-js';
import crypto from 'node:crypto';

export default class Video extends VideoProvider {
export default class Video extends VideoRegEx {
get providerName() {
return 'video';
}

static get regex() {
return [
// - //example.com/video.mp4
/^https?\:\/\/.*\.(mp4|mov|webm)$/,
];
}

static getVideoId(url = '') {
return super.getVideoId(url) ? CryptoJS.MD5(url).toString(CryptoJS.enc.Hex) : undefined;
return super.getVideoId(url) ? crypto.createHash('md5').update(url).digest('hex') : undefined;
}

getThumbnail_asVideoUrl() {
Expand Down
10 changes: 10 additions & 0 deletions netlify/functions/classes/Providers/VideoRegEx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import VideoProvider from '../VideoProvider.js';

export default class VideoRegEx extends VideoProvider {
static get regex() {
return [
// - //example.com/video.mp4
/^https?\:\/\/.*\.(mp4|mov|webm)$/,
];
}
}
2 changes: 1 addition & 1 deletion netlify/functions/classes/cloudinary.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { v2 as cloudinary } from 'cloudinary';
import crypto from 'crypto';
import crypto from 'node:crypto';

const { USE_HIGH_QUALITY = false } = process.env;

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
},
"dependencies": {
"@types/node": "^20.12.12",
"crypto-js": "^4.1.1",
"clipboard": "^2.0.11",
"cloudinary": "~1.33.0",
"hint.css": "^2.7.0",
Expand Down
8 changes: 0 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Prism from 'prismjs';
import NProgress from 'nprogress';

import { load as loadMarkdown } from './markdown';
import Video from '../../netlify/functions/classes/Providers/Video';
import VideoRegEx from '../../netlify/functions/classes/Providers/VideoRegEx';

import imageNotFound from '../images/not-found.jpg';
import imageLoading from '../images/loading.jpg';
Expand Down Expand Up @@ -180,7 +180,7 @@ export const load = () => {

memoFormSubmit = newMemoFormSubmit;

if (Video.check(domElements.url)) {
if (VideoRegEx.check(domElements.url)) {
videoConverter(domElements.title, domElements.url, domElements.showPlayIcon);
} else {
imageJsonConverter(domElements.title, domElements.url, domElements.showPlayIcon);
Expand Down

0 comments on commit 7d35b20

Please sign in to comment.