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

Comparing version 2.0.2 to 2.0.3

22

lib/index.js

@@ -11,8 +11,7 @@ "use strict";

var config = {
enable: true
mode: 'cdn'
};
exports.config = config;
var hostname = window.location.hostname;
var messages = {
unset: 'CDN path has not been set. Please use [install] to set it.'
unset: 'CDN path has not been installed. Please use [install] to set it up.'
};

@@ -27,11 +26,20 @@

var path = function path(relativePath) {
var path = config.path,
mode = config.mode;
var p = _typeof(relativePath) === 'object' ? relativePath["default"] : relativePath;
if (!config.path) {
console.log(messages.unset);
if (!path) {
console.log("%c[lesca-cdn-path]%c".concat(messages.unset), 'color:#fff; background-color:#42a5f5;', 'color:#fff; background-color:#f57c00;');
return p;
}
if (!config.enable) return p;
return false ? p : "".concat(config.path).concat(p.split('./').join('')); //hostname === 'localhost' || hostname.indexOf('github') > 0
switch (mode) {
default:
case 'cdn':
return "".concat(path).concat(p.split('./').join(''));
case 'localhost':
return p;
} // ? hostname === 'localhost' || hostname.indexOf('github') > 0
};

@@ -38,0 +46,0 @@

{
"name": "lesca-cdn-path",
"version": "2.0.2",
"version": "2.0.3",
"description": "relative path to absolute path",

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

@@ -5,3 +5,3 @@ [![NPM](https://img.shields.io/badge/NPM-ba443f?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/) [![React](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white)](https://nodejs.org/en/) [![React](https://img.shields.io/badge/-ReactJs-61DAFB?style=for-the-badge&logo=react&logoColor=white)](https://zh-hant.reactjs.org/) [![React](https://img.shields.io/badge/Less-1d365d?style=for-the-badge&logo=less&logoColor=white)](https://lesscss.org/) [![React](https://img.shields.io/badge/HTML5-E34F26?style=for-the-badge&logo=html5&logoColor=white)](https://www.w3schools.com/html/) [![React](https://img.shields.io/badge/-CSS3-1572B6?style=for-the-badge&logo=css3&logoColor=white)](https://www.w3schools.com/css/) [![NPM](https://img.shields.io/badge/DEV-Jameshsu1125-9cf?style=for-the-badge)](https://www.npmjs.com/~jameshsu1125)

Use it when image is separated from `html`.
Use it when image is separated from the `server`.

@@ -19,3 +19,3 @@ # Installation

```javascript
import { install } from 'lesca-cdn-path';
import { install, pth, config } from 'lesca-cdn-path';

@@ -25,2 +25,11 @@ install('https://cdn.hostname.com/files/');

setup mode
```javascript
import { config } from 'lesca-cdn-path';
// ? I will test at 'localhost';
config.mode = 'localhost'; // default is 'cdn'
```
In the compnenet

@@ -37,3 +46,3 @@

- use `ES6`
- use `import`

@@ -59,5 +68,5 @@ ```javascript

| Properties | description | default |
| :----------------------------------------------------- | :----------: | ------: |
| config.enable:<span style='color:gray;'>boolean</span> | use cdn file | true |
| Properties | description | default |
| :------------------------------------------------- | :--------------------------------: | ------: |
| config.mode:<span style='color:gray;'>sting</span> | url loader mode(`cdn`,`localhost`) | 'cdn' |

@@ -64,0 +73,0 @@ ### Features

const config = {
enable: true,
mode: 'cdn',
};
const { hostname } = window.location;
const messages = {
unset: 'CDN path has not been set. Please use [install] to set it.',
unset: 'CDN path has not been installed. Please use [install] to set it up.',
};

@@ -16,13 +14,24 @@

const path = (relativePath) => {
const { path, mode } = config;
const p = typeof relativePath === 'object' ? relativePath.default : relativePath;
if (!config.path) {
console.log(messages.unset);
if (!path) {
console.log(
`%c[lesca-cdn-path]%c${messages.unset}`,
'color:#fff; background-color:#42a5f5;',
'color:#fff; background-color:#f57c00;'
);
return p;
}
if (!config.enable) return p;
switch (mode) {
default:
case 'cdn':
return `${path}${p.split('./').join('')}`;
return false ? p : `${config.path}${p.split('./').join('')}`;
case 'localhost':
return p;
}
//hostname === 'localhost' || hostname.indexOf('github') > 0
// ? hostname === 'localhost' || hostname.indexOf('github') > 0
};

@@ -29,0 +38,0 @@

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