Socket
Book a DemoInstallSign in
Socket

koa-combo-parse

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-combo-parse

简单的koa模块, 解析combo的url.

0.2.3
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

koa-combo-parse

一个简单的koa中间件, 用于解析combo的url.

安装

npm install koa-combo-parse --save

例子

const path = require('path');
const app = require('koa')();
const comboParse = require('koa-combo-parse');

app.use(comboParse({
    miniCSS: true,
    base: path.resolve(__dirname, './htdocs')
}));

参数说明

miniCSS(boolean)

标识是否压缩CSS, 默认为false.

提供两种方式标识是否压缩CSS

全局设置miniCSS之后,会忽略_mcss的值. 若压缩出现异常, 则会返回未压缩的代码

  • 初始化插件的时候设置miniCSStrue, 则所有combo的css都会压缩之后输出到客户端
  • 单个combo的url中增加_mcss字段,设置为truey, 则该url对应的文件压缩后输出

例:

// 第一种情况(两个URL中解析出的CSS, 均会做压缩处理)
http://www.ooxx.com/??a.css,b.css&_mcss=true
http://www.ooxx.com/??a.css,b.css

// 第二种情况(前两个URL解析出的CSS会做压缩处理)
http://www.ooxx.com/??a.css,b.css&_mcss=true
http://www.ooxx.com/??a.css,b.css&_mcss=y
http://www.ooxx.com/??a.css,b.css&_mcss=1
http://www.ooxx.com/??a.css,b.css

base(string)

静态资源根目录(解析结果会拼接该目录和pathname作为文件所在目录)

解析规则

以上方demo中的配置为例

目标URL: http://www.ooxx.com/js/lib/??a.js,b.js,c.js

path.resolve(__dirname, './htdocs') => /home/ooxx/www/htdocs

/home/ooxx/www/htdocs/js/lib/a.js
/home/ooxx/www/htdocs/js/lib/b.js
/home/ooxx/www/htdocs/js/lib/c.js

url中只会获取?开头的数据, 即http://www.ooxx.com/js/lib/??a.js,b.js,c.js&_=12323&后的数据会被抛弃(使用过程中, 应避免在query里出现多个以?开头的数据)

DEBUG

DEBUG=koa-combo-parse

Keywords

koa-combo-parse

FAQs

Package last updated on 01 Jul 2016

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.