# html-proxy

> html proxy for flexcombo

Latest version **0.0.8** (published 2014-07-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install html-proxy
pnpm add html-proxy
yarn add html-proxy
bun add html-proxy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2014-07-07 |
| First published | 2014-04-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | dickeylth |
| Maintainers | dickeylth, bachi |
| Keywords | html, replace, proxy |

## Links

- npm: https://www.npmjs.com/package/html-proxy
- Repository: git@github.com:dickeylth/html-proxy
- Homepage: https://github.com/dickeylth/html-proxy
- Issues: https://github.com/dickeylth/html-proxy/issues
- npm.io page: https://npm.io/package/html-proxy

## Dependencies (4)

- [juicer](https://npm.io/package/juicer.md) ^0.6.5-stable-p2
- [cheerio](https://npm.io/package/cheerio.md) ^0.15.0
- [request](https://npm.io/package/request.md) ^2.34.0
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.2.11

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.0.8 (latest) — 2014-07-07
- 0.0.7 — 2014-07-03
- 0.0.6 — 2014-07-02
- 0.0.5 — 2014-07-02
- 0.0.4 — 2014-05-28
- 0.0.2 — 2014-04-25
- 0.0.1 — 2014-04-22

## README

## html-proxy

为 `grunt-flexcombo` 提供的 html 区块代理功能。

`npm install html-proxy --save`

### 使用方法

	var HTMLProxy = require('html-proxy'),
    	htmlProxy;
    
    

    // 初始化 HTML-Proxy 实例
    if (options.htmlProxy) {
        htmlProxy = new HTMLProxy({
            htmlProxyConfig: options.htmlProxy,
            htmlProxyPort: options.htmlProxyPort,
            needServer: true
        });
    }
    
    
    // 整合 reverse-proxy，在反向代理中根据 url 重写反向代理配置
    // 检查是否匹配HTML-Proxy中的某个URL RegExp
    htmlProxy && (config = htmlProxy.exportConfigForRProxy(req, config));
        
       
### API

#### 构造函数

	new HTMLProxy({
        htmlProxyConfig: options.htmlProxy,
        htmlProxyPort: options.htmlProxyPort,
        needServer: true
    });
    
- `htmlProxyConfig` : 指定要代理的各个 url 以及需要替换的区块和选择器
- `htmlProxyPort` : `html-proxy` 服务工作的端口号，默认为 `8090`
- `needServer` : 是否需要启动代理服务，如果只用到 build 阶段的区块替换功能，不需要开启本地服务

#### `replaceDom`

    /**
     * 替换 HTML 字符串中指定 dom 的内容
     * @param str {String} HTML 字符串
     * @param replacements {Array} 替换配置[{selector: 'xxx', fragment: 'path'}, {...}]
     * @returns {String} 替换后的 HTML 字符串
     */
    replaceDom: function (str, replacements) {
        
    }

#### `exportConfigForRProxy`

    /**
     * 对匹配上的请求 url, 配置 RProxy 反向代理的 config， 使其转发请求到 html-proxy 服务
     * @param request {Object} 请求对象
     * @param config {Object} reverse-proxy 的请求配置
     * @return config {Object} 返回配置
     *
     */
    exportConfigForRProxy: function (request, config) {
        
    }

### History

- [0.0.8] [iconv-lite](https://www.npmjs.org/package/iconv-lite#readme) 不支持 GB2312，兼容为 GBK 处理
- [0.0.7] fix 包含中文 url 导致 matchIdx 为 `undefined`
- [0.0.6] 移除不太好用的 js-beautify 的格式化 html 功能
- [0.0.5] Bugfix
- [0.0.1] 初始功能

---
_Source: https://npm.io/package/html-proxy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
