Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/derhuerst/wiki-article-name-encoding
Encode & decode Wiki(pedia) article names/slugs.
https://github.com/derhuerst/wiki-article-name-encoding
article slug url-safe wiki wikipedia
Last synced: 7 days ago
JSON representation
Encode & decode Wiki(pedia) article names/slugs.
- Host: GitHub
- URL: https://github.com/derhuerst/wiki-article-name-encoding
- Owner: derhuerst
- License: isc
- Created: 2017-09-30T14:51:53.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-05T10:23:54.000Z (over 4 years ago)
- Last Synced: 2024-11-04T17:26:35.027Z (10 days ago)
- Topics: article, slug, url-safe, wiki, wikipedia
- Language: JavaScript
- Homepage: https://github.com/derhuerst/wiki-article-name-encoding
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# wiki-article-name-encoding
**Encode & decode Wiki(pedia) article names/[slugs](https://en.wikipedia.org/wiki/Semantic_URL#Slug).** See [more details](https://en.wikipedia.org/wiki/Wikipedia:Page_name#Spaces.2C_underscores_and_character_coding).
[![npm version](https://img.shields.io/npm/v/wiki-article-name-encoding.svg)](https://www.npmjs.com/package/wiki-article-name-encoding)
[![build status](https://img.shields.io/travis/derhuerst/wiki-article-name-encoding.svg)](https://travis-ci.org/derhuerst/wiki-article-name-encoding)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/wiki-article-name-encoding.svg)
[![chat on gitter](https://badges.gitter.im/derhuerst.svg)](https://gitter.im/derhuerst)
[![support me on Patreon](https://img.shields.io/badge/support%20me-on%20patreon-fa7664.svg)](https://patreon.com/derhuerst)## Installing
```shell
npm install wiki-article-name-encoding
```## Usage
```js
const {encode, decode} = require('wiki-article-name-encoding')const encoded = encode('Walentynów, Lipsko County')
console.log(encoded) // Walentyn%C3%B3w,_Lipsko_County
console.log(decode(encoded)) // Walentynów, Lipsko County
````encode` and `decode` can also be loaded separately:
```js
const encode = require('wiki-article-name-encoding/encode')
const decode = require('wiki-article-name-encoding/decode')
```## API
```js
encode(name, fileSafe = false) => slug
decode(slug) => name
```If you pass `true` for `fileSafe`, `encode` will use [`filename-reserved-regex`](https://github.com/sindresorhus/filename-reserved-regex#readme) to figure out with characters *not to keep unencoded*. It will not respect [Windows reserved file names](https://github.com/sindresorhus/filename-reserved-regex#filenamereservedregexwindowsnames).
## Contributing
If you have a question or have difficulties using `wiki-article-name-encoding`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to [the issues page](https://github.com/derhuerst/wiki-article-name-encoding/issues).