# jason-wxhash

> 解决使用 hash url 微信分享时，页面指向错误的问题

Latest version **0.1.1** (published 2019-01-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install jason-wxhash
pnpm add jason-wxhash
yarn add jason-wxhash
bun add jason-wxhash
```

## 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.1.1 |
| Published | 2019-01-16 |
| First published | 2019-01-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | q-jason |
| Maintainers | q-jason |
| Keywords | wechat, js, vue-router, react-router |

## Links

- npm: https://www.npmjs.com/package/jason-wxhash
- Repository: https://github.com/q-jason/jason-wxhash
- Homepage: https://github.com/q-jason/jason-wxhash#readme
- Issues: https://github.com/q-jason/jason-wxhash/issues
- npm.io page: https://npm.io/package/jason-wxhash

## Dependencies (1)

- [qs](https://npm.io/package/qs.md) ^6.6.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.1 (latest) — 2019-01-16
- 0.1.0 — 2019-01-11

## README

# jason-wxhash
> 导致使用 hash url 微信分享时，指向错误的问题

## 思路：
1. 将带有 hash 的 url 转成查询字符串（wxhash）连同其他查询字符串拼接到当前 url 路径之后
2. 页面进入时，检查是否含有指定的查询字符串（wxhash）
   1. 若有，则使用 history.replaceState 改变 url
3. 基于 url 的功能，均使用改变后的 hash url

## install

```bash
npm i --save jason-wxhash
```

```javascript
import wxHash from 'jason-wxhash';

// 获取处理后的 url
// 参数为默认值
let url = wxHash({
  url: location.origin + location.pathname + location.hash,
  qs: ''
});

wx.updateAppMessageShareData({
  title: '分享标题',
  desc: '分享描述',
  // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  link: url,
  imgUrl: '分享图标'
})
```

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