mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Use replaceAll package for older node support
This commit is contained in:
parent
a72dba232c
commit
fe9040ada4
1 changed files with 12 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
|
|
||||||
import has from 'just-has'
|
import has from 'just-has'
|
||||||
|
// https://anguscroll.com/just/just-replace-all
|
||||||
|
import replaceAll from 'just-replace-all'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getAppType
|
getAppType
|
||||||
|
|
@ -21,13 +23,21 @@ function makeDescription ( listing ) {
|
||||||
return `Latest reported support status of ${ listing.name } on Apple Silicon and Apple M1 Pro and M1 Max Processors.`
|
return `Latest reported support status of ${ listing.name } on Apple Silicon and Apple M1 Pro and M1 Max Processors.`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function convertYoutubeImageUrl ( stringWithUrls, extension ) {
|
||||||
|
let workingString = stringWithUrls
|
||||||
|
|
||||||
|
workingString = replaceAll( stringWithUrls, 'ytimg.com/vi/', `ytimg.com/vi_${ extension }/`)
|
||||||
|
|
||||||
|
workingString = workingString.replace(/.png|.jpg|.jpeg/g, `.${ extension }`)
|
||||||
|
|
||||||
|
return workingString
|
||||||
|
}
|
||||||
|
|
||||||
export function getVideoImages ( video ) {
|
export function getVideoImages ( video ) {
|
||||||
|
|
||||||
// Catch the case where the video has no thumbnails
|
// Catch the case where the video has no thumbnails
|
||||||
if ( !has( video, 'thumbnail' ) ) throw new Error('No thumbnail found')
|
if ( !has( video, 'thumbnail' ) ) throw new Error('No thumbnail found')
|
||||||
|
|
||||||
const convertYoutubeImageUrl = ( stringWithUrls, extension ) => stringWithUrls.replaceAll('ytimg.com/vi/', `ytimg.com/vi_${ extension }/`).replace(/.png|.jpg|.jpeg/g, `.${ extension }`)
|
|
||||||
|
|
||||||
const webpSource = {
|
const webpSource = {
|
||||||
...video.thumbnail,
|
...video.thumbnail,
|
||||||
srcset: convertYoutubeImageUrl( video.thumbnail.srcset, 'webp' ),
|
srcset: convertYoutubeImageUrl( video.thumbnail.srcset, 'webp' ),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue