Socket
Socket
Sign inDemoInstall

lesca-cdn-path

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lesca-cdn-path

relative path to absolute path


Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Install size
218 kB
Created
Weekly downloads
 

Readme

Source

NPM React React React React React NPM

Why use it.

Use it when image is separated from the server.

Installation

npm install lesca-cdn-path --save

Usage

As a Node module: install in entry js.

import { install } from 'lesca-cdn-path';

install('https://cdn.hostname.com/files/');

setup mode

import { config } from 'lesca-cdn-path';

// ? test at 'localhost'?;
config.mode = 'localhost'; // default is 'cdn'

In the compnenet

  • use require
import { path } from 'lesca-cdn-path';

const component = () => <img src={path(require('./img/image.jpg'))} />;
// http://localhost:8080/img/image.jpg => https://cdn.hostname.com/files/img/image.jpg
  • use import
import { path } from 'lesca-cdn-path';
import Image from './img/image.jpg';

const component = () => <img src={path(Image)} />;
// http://localhost:8080/img/image.jpg => https://cdn.hostname.com/files/img/image.jpg

Development

Methods

methoddescriptionreturn
.install(cdn-path:string)set the base path was generated by the CDNvoid
.path(local-path:string)localhost url pathcdn-path

Properties

Propertiesdescriptionoptionsdefault
config.mode:stingurl loader mode.cdn, localhost'cdn'

Features

  • maintain if necessary

Keywords

FAQs

Last updated on 28 Mar 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc