Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

strapi-cdn-url-rewrite

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strapi-cdn-url-rewrite - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

28

index.js

@@ -22,13 +22,29 @@ const { flatten, unflatten } = require('safe-flat')

crawl = data => {
const flattened = flatten(data)
for (let prop in flattened) {
if (typeof flattened[prop] === 'string' && flattened[prop].startsWith(this.storage)) {
flattened[prop] = flattened[prop].replace(this.storage, this.cdn)
}
}
return unflatten(flattened)
}
cdnRewrite = async data => {
try {
const flattened = flatten(await flatten(data)['0'])
data = await data
for (let prop in flattened) {
if (typeof flattened[prop] === 'string' && flattened[prop].startsWith(this.storage)) {
flattened[prop] = flattened[prop].replace(this.storage, this.cdn)
if (Array.isArray(data)) {
let out = []
for (let item of data) {
out.push(this.crawl(await item))
}
return out
} else {
return this.crawl(data)
}
return unflatten(flattened)
} catch (err) {

@@ -35,0 +51,0 @@ console.error(err)

{
"name": "strapi-cdn-url-rewrite",
"version": "0.1.0",
"version": "0.1.1",
"description": "Strapi controller module to rewrite upload URLs to CDN",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc