# vue-typo-redirect

> A vue component helps accesing to routes with typos

Latest version **1.0.1** (published 2022-06-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install vue-typo-redirect
pnpm add vue-typo-redirect
yarn add vue-typo-redirect
bun add vue-typo-redirect
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-06-12 |
| First published | 2022-06-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Murat TURAN |
| Maintainers | snowron |
| Keywords | typo, vue typo, vue router, vue redirect, routes, middleware, typo, redirect |

## Links

- npm: https://www.npmjs.com/package/vue-typo-redirect
- Repository: https://github.com/snowron/vue-typo-redirect
- Homepage: https://github.com/snowron/vue-typo-redirect#readme
- Issues: https://github.com/snowron/vue-typo-redirect/issues
- npm.io page: https://npm.io/package/vue-typo-redirect

## Dependencies (2)

- [js-levenshtein](https://npm.io/package/js-levenshtein.md) ^1.1.6
- [fuzzy-comparison](https://npm.io/package/fuzzy-comparison.md) ^2.0.0

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-06-12
- 1.0.0 — 2022-06-12

## README

# vue-typo-redirect

Make your users happy with catch typos with middleware and redirect to right one. 

Works with Vue

## Install 

```bash 
  npm i vue-typo-redirect
```
    
## Usage
Add wildcard route and set component as TypoRedirect. It gets the request path and analyzes it with rules and redirects.

```js
import TypoRedirect from "vue-typo-redirect";

const routes = [
    ...
  {
    path: "**",
    component: TypoRedirect,
    props: (route) => ({
      currentRoute: route,
      routes: [ "/chat", "/about/:id"],
    }),
  },
];

```

If you don't want to make an array with manuel processing then don't add prop it will gather all defined routes from this.$router except "**" and "/".

```js
import TypoRedirect from "vue-typo-redirect";

const routes = [
    ...
  {
    path: "**",
    component: TypoRedirect,
    props: (route) => ({
      currentRoute: route,
    }),
  },
];

```

## Demo

[Tests](https://github.com/snowron/vue-typo-redirect/blob/master/src/tests/TypoRedirect.spec.js)


```bash
➜ curl "http://localhost:3000/abouc/"           
Found. Redirecting to /about/%                                                                                                                                                                             

➜ curl "http://localhost:3000/abouct/"
Found. Redirecting to /about/%    

➜ curl "http://localhost:3000/chay/123"
Found. Redirecting to /chat/123%     
```

## Tests

```bash
  npm run test
```

## Options

| Parameter        | Type            | Desc                                                                                      |
| :--------------- | :-------------- | :---------------------------------------------------------------------------------------- |
| `routes`         | `array<string>` | whitelist routes                                                                          |
| `levenThreshold` | `number`        | the levenstein algorithm's threshold value                                                |
| `fuzzyThreshold` | `number`        | fuzzy comparasion algorithm's threshold value                                             |
| `currentRoute`   | `object`        | vue routers route prop                                                                    |
| `wildcardRoute`  | `string`        | if it cant redirect any route redirect to 404 page or another wildcard strategy component |

## Lisans

[MIT](https://choosealicense.com/licenses/mit/)

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