devstar插件
This commit is contained in:
13
node_modules/speakingurl/.editorconfig
generated
vendored
Normal file
13
node_modules/speakingurl/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
21
node_modules/speakingurl/.jsbeautifyrc
generated
vendored
Normal file
21
node_modules/speakingurl/.jsbeautifyrc
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"ident_size": 4,
|
||||
"indent_char": " ",
|
||||
"indent_level": 0,
|
||||
"var_line_reindented": true,
|
||||
"chain_extra_indentation": 2,
|
||||
"indent_with_tabs": false,
|
||||
"preserve_newlines": true,
|
||||
"max_preserve_newlines": 2,
|
||||
"jslint_happy": true,
|
||||
"brace_style": "collapse",
|
||||
"keep_array_indentation": false,
|
||||
"keep_function_indentation": false,
|
||||
"eval_code": false,
|
||||
"unescape_strings": false,
|
||||
"break_chained_methods": false,
|
||||
"space_before_conditional": true,
|
||||
"space_after_anon_function": true,
|
||||
"jslint_happy": false,
|
||||
"wrap_line_length": 242
|
||||
}
|
2
node_modules/speakingurl/.jshintignore
generated
vendored
Normal file
2
node_modules/speakingurl/.jshintignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
.git/
|
18
node_modules/speakingurl/.jshintrc
generated
vendored
Normal file
18
node_modules/speakingurl/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"camelcase": true,
|
||||
"onevar": false,
|
||||
"immed": true,
|
||||
"indent": 4,
|
||||
"newcap": true,
|
||||
"nonew": true,
|
||||
"trailing": true,
|
||||
"browser": true,
|
||||
"devel": true,
|
||||
"jquery": true,
|
||||
"node": true,
|
||||
"globals": {
|
||||
"module": true,
|
||||
"require": true,
|
||||
"console": true
|
||||
}
|
||||
}
|
56
node_modules/speakingurl/.npmignore
generated
vendored
Normal file
56
node_modules/speakingurl/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
*~
|
||||
_*
|
||||
*.sublime-*
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
*.old
|
||||
.idea
|
||||
.zedstate
|
||||
.vscode
|
||||
|
||||
coverage
|
||||
coverage.html
|
||||
lib-cov
|
||||
|
||||
# components
|
||||
components
|
||||
build
|
||||
|
||||
# dev temp testing scripts
|
||||
dev-*.js
|
||||
|
||||
# Compiled source #
|
||||
###################
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.so
|
||||
|
||||
# Packages #
|
||||
############
|
||||
*.7z
|
||||
*.dmg
|
||||
*.gz
|
||||
*.iso
|
||||
*.jar
|
||||
*.rar
|
||||
*.tar
|
||||
*.zip
|
||||
*.tgz
|
||||
*.gem
|
||||
|
||||
# Logs and databases #
|
||||
######################
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
*.db
|
||||
log/
|
||||
logs/
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store*
|
||||
Icon?
|
9
node_modules/speakingurl/.travis.yml
generated
vendored
Normal file
9
node_modules/speakingurl/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.12"
|
||||
- "0.11"
|
||||
- "0.10"
|
||||
before_script:
|
||||
- npm install
|
||||
notifications:
|
||||
email: false
|
55
node_modules/speakingurl/CHANGELOG.md
generated
vendored
Normal file
55
node_modules/speakingurl/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
Changelog
|
||||
=========
|
||||
- v14.0.1 Empty minified file; Thanks to https://github.com/redaxmedia
|
||||
- v14.0.0 Add Swedish #101 Thanks to https://github.com/simison
|
||||
- v13.0.0 Add Vietnamese missing charMap key #88; Thanks to https://github.com/aduycuong // [Bower] invalid-meta The "main" field cannot contain minified files #91 Thanks to https://github.com/stonio
|
||||
- v12.0.0 Georgian Support Added! #95 Thanks to https://github.com/vdanelia and support from https://github.com/redaxmedia // Improved README (yarn install option, https links, etc.) #97 Thanks to https://github.com/apepper // Move static maps outside getSlug (performance) #96 Thanks to https://github.com/kwiatkk1 // Improved docs - lang option can be string or boolean #89 Thanks to https://github.com/stonio
|
||||
- v11.0.0 #87 Add Finnish transliteration for symbols; #85 Added new currencies; #84 Update README.md; #83 Various czech language fixes;#82 Add lithuanian transliteration for symbols; Fix: Ω should be transliterated to O
|
||||
- v10.0.0 Add persian; Update dependencies
|
||||
- v9.0.0 fix of "Title Case error while accent on First Character for each word #72"
|
||||
- v8.0.2 fix the fix; problems with release v8.0.1 with building speakingurl-min.js
|
||||
- v8.0.1 merge #71 Improve sprockets fix
|
||||
- v8.0.0 Cleanup Russian transliteration to ICAO https://en.wikipedia.org/wiki/Romanization_of_Russian
|
||||
- v7.0.0 Add Dhivehi translations; thanks to https://github.com/jawish/;
|
||||
- v6.0.0 Add Catalan translations #64; thanks to https://github.com/alexandernst/; Add Finnish char map #65; thanks to https://github.com/jmheik/
|
||||
- v5.0.1 bugfix #62; thanks to https://github.com/jdiprizio
|
||||
- v5.0.0 add Ukranian #60, Latvian #57 symbol translations; update devDependencies
|
||||
- v4.0.0 add new 'symbols' option, now you can explicit disable converting symbols, but use 'lang' specific transliteration; add romanian chars/symbol translation #52
|
||||
- v3.0.0 add Romanian,Polish,Czech,Serbian,Latvian,Azerbaijani,add support for polish symbols
|
||||
- v2.0.0 update charmap with Vietnamese chars) thanks to Lê Anh Tuấn https://github.com/lATAl
|
||||
- v1.1.5 cleanup horror
|
||||
- v1.1.4 forgot to generate the v1.1.3 minified version, but nevermind, there wasn't any code changes ;-)
|
||||
- v1.1.3 cleanup
|
||||
- v1.1.2 add Rails asset pipeline support (thanks to @retrorubies / https://github.com/simi\)
|
||||
- v1.1.1 cleanup, update dev dependencies
|
||||
- v1.1.0 custom config can be an array, all chars are added to allowed chars
|
||||
- v1.0.0 fix #47; bumpup to semver ;-)
|
||||
- v0.20.0 add support for hungarian #45
|
||||
- v0.19.0 add support for burmese #44
|
||||
- v0.18.1 cleanup, update dev dependencies
|
||||
- v0.18.0 fix #43; add chars to turkish langCharMap; language specific character transliteration
|
||||
- v0.17.0 pass global to anonymous function #42
|
||||
- v0.16.0 add support for italian
|
||||
- v0.15.0 bugfix #38
|
||||
- v0.14.0 add support for turkish
|
||||
- v0.13.1 after publishing corrected 0.12.5, the 0.13.0 was unpublished WTF?
|
||||
- v0.13.0 not published
|
||||
- v0.12.5 reverted v0.12.3
|
||||
- v0.12.4 deprecated; change to map, mistakenly without bumpup minor version!
|
||||
- v0.12.3 switch to gulpjs
|
||||
- v0.12.2 corrupt gulpfile, not published to npm registry
|
||||
- v0.12.1 update devDep
|
||||
- v0.12.0 add support for Czech and Slovak
|
||||
- v0.11.0 add support for Vietnamese
|
||||
- v0.10.0 changes in greek transliteration mapping table
|
||||
- v0.9.1 add support for Dutch
|
||||
- v0.9.0 updated dev dependencies; because of dep. we are only compatible with node > 0.10.x
|
||||
- v0.8.4 last version compatible with node v0.8.x
|
||||
- v0.8.0 add feature to set 'lang' to true or false to deactivate symbol translation
|
||||
- v0.7.0 add titleCase feature #26
|
||||
- v0.6.0 add symbol translation pt
|
||||
- v0.5.0 enhance custom replacement; Add support for "black-listed" words #20 - keep old behavior for single character replacement - add custom replacement for string to string|char|'' // '' ~= remove
|
||||
- v0.4.0 add support for Arabic
|
||||
- v0.3.0 add Indian Rupee and Pfennig to currency map
|
||||
- v0.2.21 fix #17; if symbol at the end of input string
|
||||
- v0.2.18 add amd-support
|
137
node_modules/speakingurl/Gulpfile.js
generated
vendored
Normal file
137
node_modules/speakingurl/Gulpfile.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
var gulp = require('gulp');
|
||||
var plugin = require('gulp-load-plugins')();
|
||||
var fs = require('fs');
|
||||
var exec = require('child_process').exec;
|
||||
var argv = require('minimist')(process.argv.slice(2));
|
||||
|
||||
var path = {
|
||||
rootdir: './',
|
||||
lib: ['./lib/**/*.js'],
|
||||
libdir: './lib/',
|
||||
test: ['./test/**/*.js'],
|
||||
testdir: './test/',
|
||||
build: ['package.json', 'component.json', 'bower.json', 'README.md', 'speakingurl.min.js'],
|
||||
json: ['package.json', 'component.json', 'bower.json'],
|
||||
readme: './README.md',
|
||||
|
||||
target: './speakingurl.min.js'
|
||||
};
|
||||
|
||||
var banner = ['/**',
|
||||
' * <%= pkg.name %>',
|
||||
' * @version v<%= pkg.version %>',
|
||||
' * @link <%= pkg.homepage %>',
|
||||
' * @license <%= pkg.licenses[0].type %>',
|
||||
' * @author <%= pkg.author.name %>',
|
||||
' */'
|
||||
].join('\n');
|
||||
|
||||
gulp.task('beautify', function (done) {
|
||||
|
||||
gulp.src(path.lib)
|
||||
.pipe(plugin.jsbeautifier({
|
||||
config: '.jsbeautifyrc',
|
||||
mode: 'VERIFY_AND_WRITE'
|
||||
}))
|
||||
.pipe(gulp.dest(path.libdir));
|
||||
|
||||
gulp.src(path.test)
|
||||
.pipe(plugin.jsbeautifier({
|
||||
config: '.jsbeautifyrc',
|
||||
mode: 'VERIFY_AND_WRITE'
|
||||
}))
|
||||
.pipe(gulp.dest(path.testdir));
|
||||
|
||||
gulp.src(path.json)
|
||||
.pipe(plugin.jsbeautifier({
|
||||
config: '.jsbeautifyrc',
|
||||
mode: 'VERIFY_AND_WRITE'
|
||||
}))
|
||||
.pipe(gulp.dest(path.rootdir));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('test', function () {
|
||||
|
||||
return gulp.src(path.test, {
|
||||
read: false
|
||||
})
|
||||
.pipe(plugin.mocha({
|
||||
reporter: 'spec',
|
||||
globals: {
|
||||
should: require('should')
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
gulp.task('jshint', ['beautify'], function () {
|
||||
|
||||
return gulp.src(path.lib, path.json)
|
||||
.pipe(plugin.jshint('.jshintrc'), {
|
||||
verbose: true
|
||||
})
|
||||
.pipe(plugin.jshint.reporter('jshint-stylish'));
|
||||
});
|
||||
|
||||
gulp.task('uglify', ['jshint'], function (done) {
|
||||
|
||||
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
|
||||
|
||||
return gulp.src(path.lib)
|
||||
.pipe(plugin.uglify())
|
||||
.pipe(plugin.header(banner, {
|
||||
pkg: pkg
|
||||
}))
|
||||
.pipe(plugin.rename(path.target))
|
||||
.pipe(gulp.dest(path.rootdir));
|
||||
});
|
||||
|
||||
gulp.task('bumpup', ['bumpup-version'], function () {
|
||||
|
||||
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
|
||||
|
||||
// insert newsest version
|
||||
return gulp.src(path.readme)
|
||||
.pipe(plugin.replace(
|
||||
/cdnjs.cloudflare.com\/ajax\/libs\/speakingurl\/\d{1,1}\.\d{1,2}\.\d{1,2}\/speakingurl.min.js/g,
|
||||
'cdnjs.cloudflare.com/ajax/libs/speakingurl/' + pkg.version + '/speakingurl.min.js'))
|
||||
.pipe(plugin.replace(
|
||||
/cdn.jsdelivr.net\/speakingurl\/\d{1,1}\.\d{1,2}\.\d{1,2}\/speakingurl.min.js/g,
|
||||
'cdn.jsdelivr.net/speakingurl/' + pkg.version + '/speakingurl.min.js'))
|
||||
.pipe(gulp.dest(path.rootdir));
|
||||
});
|
||||
|
||||
gulp.task('bumpup-version', function () {
|
||||
|
||||
return gulp.src(path.json)
|
||||
.pipe(plugin.bump({
|
||||
type: argv.major ? 'major' : (argv.minor ? 'minor' : 'patch')
|
||||
}))
|
||||
.pipe(gulp.dest(path.rootdir));
|
||||
});
|
||||
|
||||
gulp.task('release', function (done) {
|
||||
|
||||
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
|
||||
var tag = 'v' + pkg.version;
|
||||
var message = 'Release ' + tag;
|
||||
var execute = [
|
||||
'npm rm speakingurl -g',
|
||||
'npm install . -g',
|
||||
'git add .',
|
||||
'git commit -m "Release ' + tag + '"',
|
||||
'git tag ' + tag + ' -m "Release ' + tag + '"',
|
||||
'git push -u origin master',
|
||||
'git push -u origin master --tags',
|
||||
'npm publish'
|
||||
].join('\n');
|
||||
|
||||
exec(execute, done());
|
||||
});
|
||||
|
||||
gulp.task('watch', function () {
|
||||
gulp.watch([path.json, path.lib], ['jshint', 'test']);
|
||||
});
|
||||
|
||||
gulp.task('default', ['test', 'jshint', 'uglify']);
|
12
node_modules/speakingurl/LICENSE
generated
vendored
Normal file
12
node_modules/speakingurl/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
The BSD 3-Clause License (BSD3)
|
||||
|
||||
Copyright (c) 2013-2017 Sascha Droste <pid@posteo.net>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
13
node_modules/speakingurl/Makefile
generated
vendored
Normal file
13
node_modules/speakingurl/Makefile
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Default task
|
||||
all: install
|
||||
|
||||
# Install dependencies
|
||||
install:
|
||||
@npm install
|
||||
|
||||
# Run test suites
|
||||
tests: tests-unit
|
||||
|
||||
# Run unit tests
|
||||
tests-unit:
|
||||
@./node_modules/.bin/mocha --ui bdd --reporter spec --colors --recursive ./test
|
422
node_modules/speakingurl/README.md
generated
vendored
Normal file
422
node_modules/speakingurl/README.md
generated
vendored
Normal file
@@ -0,0 +1,422 @@
|
||||
SpeakingURL
|
||||
===========
|
||||
|
||||
[](https://travis-ci.org/pid/speakingurl)
|
||||
[](https://badge.fury.io/js/speakingurl)
|
||||
[](https://badge.fury.io/bo/speakingurl)
|
||||
[](https://badge.fury.io/rb/speakingurl-rails)
|
||||
[](https://gitter.im/pid/speakingurl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
[](https://flattr.com/thing/1418477/pidspeakingurl-on-GitHub)
|
||||
|
||||
|
||||
> Generate a slug with a lot of options; create a so-called [Semantic URL](https://en.wikipedia.org/wiki/Semantic_URL) or 'Clean URL' or 'Pretty URL' or 'nice-looking URL' or 'Speaking URL' or 'user-friendly URL' or 'SEO-friendly URL' from a string. This module aims to transliterate the input string.
|
||||
|
||||
For use in browser and server - no dependencies!
|
||||
|
||||
##### NPM Badge
|
||||
|
||||
[](https://npmjs.org/package/speakingurl)
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
#### [npm](https://npmjs.org/package/speakingurl)
|
||||
|
||||
```shell
|
||||
npm install speakingurl --save
|
||||
```
|
||||
|
||||
#### [yarn](https://yarnpkg.com)
|
||||
|
||||
```shell
|
||||
yarn add speakingurl --dev
|
||||
```
|
||||
|
||||
#### [Bower](https://bower.io)
|
||||
|
||||
```shell
|
||||
bower install --save speakingurl
|
||||
```
|
||||
|
||||
#### [Component](https://github.com/component/component)
|
||||
|
||||
```shell
|
||||
component install pid/speakingurl
|
||||
```
|
||||
|
||||
#### [Ruby on Rails](http://rubyonrails.org/)
|
||||
|
||||
```ruby
|
||||
# Add to Gemfile
|
||||
gem 'speakingurl-rails'
|
||||
```
|
||||
|
||||
#### [Download Package](https://github.com/pid/speakingurl/releases)
|
||||
|
||||
copy the file speakingurl.min.js to your script directory
|
||||
|
||||
#### [CDN/cloudflare](https://www.cloudflare.com/)
|
||||
|
||||
available versions:
|
||||
|
||||
- [www.cdnjs.com/libraries/speakingurl/](https://cdnjs.com/libraries/speakingurl/)
|
||||
- use [//cdnjs.cloudflare.com/ajax/libs/speakingurl/13.0.0/speakingurl.min.js](https://cdnjs.cloudflare.com/ajax/libs/speakingurl/13.0.0/speakingurl.min.js)
|
||||
|
||||
#### [CDN/maxcdn](https://www.maxcdn.com/)
|
||||
|
||||
available versions:
|
||||
|
||||
- [www.jsdelivr.com/#!speakingurl](https://www.jsdelivr.com/#!speakingurl)
|
||||
- use [//cdn.jsdelivr.net/speakingurl/13.0.0/speakingurl.min.js](https://cdn.jsdelivr.net/speakingurl/13.0.0/speakingurl.min.js)
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
### getSlug(input, [options]);
|
||||
|
||||
`input`: {string} to convert
|
||||
|
||||
`options` {object|string} config object or separator string (see below)
|
||||
|
||||
- `options` {object}
|
||||
|
||||
- `separator` {string} default: '-'
|
||||
- char that replaces the whitespaces
|
||||
- `lang` {string|boolean} default: 'en' // ISO 639-1 Codes
|
||||
- language specific transliteration (
|
||||
- 'ar' // Arabic
|
||||
- 'az' // Azerbaijani\*
|
||||
- 'cs' // Czech
|
||||
- 'de' // German
|
||||
- 'dv' // Divehi
|
||||
- 'en' // English
|
||||
- 'es' // Spanish
|
||||
- 'fa' // Persian
|
||||
- 'fi' // Finnish
|
||||
- 'fr' // French
|
||||
- 'ge' // Georgian
|
||||
- 'gr' // Greek\*
|
||||
- 'hu' // Hungarian
|
||||
- 'it' // Italian
|
||||
- 'lt' // Lithuanian\*
|
||||
- 'lv' // Latvian
|
||||
- 'my' // Burmese
|
||||
- 'mk' // Macedonian\*
|
||||
- 'nl' // Dutch
|
||||
- 'pl' // Polish
|
||||
- 'pt' // Portuguese
|
||||
- 'ro' // Romanian
|
||||
- 'ru' // Russian
|
||||
- 'sv' // Swedish
|
||||
- 'sk' // Slovak
|
||||
- 'sr' // Serbian\*
|
||||
- 'tr' // Turkish
|
||||
- 'uk' // Ukranian
|
||||
- 'vn' // Vietnamese
|
||||
- `symbols` {boolean} default: true
|
||||
- false -> don't convert symbols
|
||||
- true -> convert symbols according to the 'lang' setting
|
||||
- `maintainCase` {boolean} default: false
|
||||
- true -\> maintain case chars
|
||||
- false -\> convert all chars to lower case
|
||||
- `titleCase` {boolean|array} default: false
|
||||
- true -\> convert input string to title-case
|
||||
- array -\> titlecase = true, but omit the words from in the array
|
||||
- `truncate` {number} default: 0
|
||||
- 0 -\> don't trim length
|
||||
- \>= 1 -\> trim to max length while not breaking any words
|
||||
- `uric` {boolean} default: false
|
||||
- true -\> additionally allow chars: ";", "?", ":", "@", "&", "=", "+", "\$", ",", "/"
|
||||
- false
|
||||
- `uricNoSlash` {boolean} default: false
|
||||
- true -\> additionally allow chars: ";", "?", ":", "@", "&", "=", "+", "\$", ","
|
||||
- `mark` {boolean} default: false
|
||||
- true -\> additionally allow chars: "-", "\_", ".", "!", "~", "\*", "'", "(", ")"
|
||||
- `custom` {object|array} default: {}
|
||||
- object -\> custom map for translation, overwrites all i.e. { '&': '\#', '\*': ' star ' }
|
||||
- array -\> add chars to allowed charMap (see example)
|
||||
|
||||
- `options` {string} separator
|
||||
|
||||
notes: default only Base64 chars are allowed (/A-Za-z0-9\_-/), setting `uric`, `uricNoSlash` or/and `mark` to `true` will add the specified chars to the list of allowed characters. The separator-character is always allowed.
|
||||
|
||||
##### Node.js
|
||||
|
||||
```js
|
||||
var getSlug = require('speakingurl');
|
||||
```
|
||||
|
||||
##### Browser
|
||||
|
||||
```html
|
||||
<script src="bower_components/speakingurl/speakingurl.min.js"></script>
|
||||
```
|
||||
|
||||
#### Ruby on Rails
|
||||
|
||||
```ruby
|
||||
# Add to application.js
|
||||
//= require speakingurl
|
||||
```
|
||||
|
||||
#### Examples
|
||||
|
||||
```js
|
||||
var slug;
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !");
|
||||
console.log(slug); // Output: schoener-titel-laesst-gruessen-bel-ete
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", '*');
|
||||
console.log(slug); // Output: schoener*titel*laesst*gruessen*bel*ete
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
separator: '_'
|
||||
});
|
||||
console.log(slug); // Output: schoener_titel_laesst_gruessen_bel_ete
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
uric: true
|
||||
});
|
||||
console.log(slug); // Output: schoener-titel-laesst-gruessen?-bel-ete
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
uricNoSlash: true
|
||||
});
|
||||
console.log(slug); // Output: schoener-titel-laesst-gruessen?-bel-ete
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
mark: true
|
||||
});
|
||||
console.log(slug); // Output: schoener-titel-laesst-gruessen!-bel-ete-!
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
truncate: 20
|
||||
});
|
||||
console.log(slug); // Output: schoener-titel
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
maintainCase: true
|
||||
});
|
||||
console.log(slug); // Output: Schoener-Titel-laesst-gruessen-Bel-ete
|
||||
|
||||
slug = getSlug("Äpfel & Birnen!", {
|
||||
lang: 'de'
|
||||
});
|
||||
console.log(slug); // Output: aepfel-und-birnen
|
||||
|
||||
slug = getSlug("မြန်မာ သာဓက", {
|
||||
lang: 'my'
|
||||
});
|
||||
console.log(slug); // Output: myanma-thadak
|
||||
|
||||
slug = getSlug('މިއަދަކީ ހދ ރީތި ދވހކވ', {
|
||||
lang: 'dv'
|
||||
});
|
||||
console.log(slug); // Output: miadhakee hd reethi dvhkv
|
||||
|
||||
slug = getSlug("Apple & Pear!", {
|
||||
lang: 'en' // lang: "en" is default, just to clarify
|
||||
});
|
||||
console.log(slug); // Output: apple-and-pear
|
||||
|
||||
slug = getSlug('Foo & Bar * Baz', {
|
||||
custom: {
|
||||
'&': ' doo '
|
||||
},
|
||||
uric:true
|
||||
});
|
||||
console.log(slug); // Output: foo-doo-bar-baz
|
||||
|
||||
slug = getSlug('Foo ♥ Bar');
|
||||
console.log(slug); // Output: foo-love-bar
|
||||
|
||||
slug = getSlug('Foo & Bar | (Baz) * Doo', {
|
||||
custom: {
|
||||
'*': 'Boo'
|
||||
},
|
||||
mark:true
|
||||
});
|
||||
console.log(slug); // Output: foo-and-bar-or-(baz)-boo-doo
|
||||
|
||||
slug = getSlug('Foo and Bar or Baz', {
|
||||
custom: {
|
||||
'and': 'und',
|
||||
'or': ''
|
||||
}
|
||||
});
|
||||
console.log(slug); // Output: foo-und-bar-baz
|
||||
|
||||
slug = getSlug('[Knöpfe]', {
|
||||
custom: [
|
||||
'[',
|
||||
']'
|
||||
]
|
||||
});
|
||||
console.log(slug); // Output: [knoepfe]
|
||||
|
||||
slug = getSlug('NEXUS4 only $299');
|
||||
console.log(slug); // Output: nexus-4-only-usd299
|
||||
|
||||
slug = getSlug('NEXUS4 only €299', {
|
||||
maintainCase: true
|
||||
});
|
||||
console.log(slug); // Output: NEXUS-4-only-EUR299
|
||||
|
||||
slug = getSlug('Don\'t drink and drive', {
|
||||
titleCase: true
|
||||
});
|
||||
console.log(slug); // Output: Don-t-Drink-And-Drive
|
||||
|
||||
slug = getSlug('Don\'t drink and drive', {
|
||||
titleCase: ['and']
|
||||
});
|
||||
console.log(slug); // Output: Don-t-Drink-and-Drive
|
||||
|
||||
slug = getSlug('Foo & Bar ♥ Foo < Bar', {
|
||||
lang: false
|
||||
});
|
||||
console.log(slug); // Output: foo-bar-foo-bar
|
||||
|
||||
slug = getSlug('Foo & Bar ♥ Foo < Bar', {
|
||||
symbols: false
|
||||
});
|
||||
console.log(slug); // Output: foo-bar-foo-bar
|
||||
|
||||
slug = getSlug('ä♥ä', {
|
||||
lang: 'tr',
|
||||
symbols: false
|
||||
});
|
||||
console.log(slug); // Output: a
|
||||
```
|
||||
|
||||
### createSlug([options])
|
||||
|
||||
`options`: {object|string} config object or separator string (see above)
|
||||
|
||||
Create your own specially configured function.
|
||||
|
||||
```js
|
||||
var options = {
|
||||
maintainCase: true,
|
||||
separator: '_'
|
||||
};
|
||||
|
||||
var mySlug = require('speakingurl').createSlug(options);
|
||||
// in browser:
|
||||
// var mySlug = createSlug(options);
|
||||
|
||||
var slug = mySlug("Schöner Titel läßt grüßen!? Bel été !");
|
||||
console.log(slug); // Output: Schoener_Titel_laesst_gruessen_Bel_ete
|
||||
```
|
||||
|
||||
Create your own specially configured function with title-case feature.
|
||||
|
||||
```js
|
||||
var options = {
|
||||
titleCase: [
|
||||
"a","an","and","as","at","but",
|
||||
"by","en","for","if","in","nor",
|
||||
"of","on","or","per","the","to","vs"
|
||||
]
|
||||
};
|
||||
|
||||
var mySlug = require('speakingurl').createSlug(options);
|
||||
// in browser:
|
||||
// var mySlug = createSlug(options);
|
||||
|
||||
var slug = mySlug('welcome to the jungle');
|
||||
console.log(slug); // Output: Welcome-to-the-Jungle
|
||||
```
|
||||
|
||||
Changelog
|
||||
---------
|
||||
|
||||
see [CHANGELOG.md](https://raw.github.com/pid/speakingurl/master/CHANGELOG.md)
|
||||
|
||||
Tests
|
||||
-----
|
||||
|
||||
[](https://travis-ci.org/pid/speakingurl)
|
||||
|
||||
```shell
|
||||
npm test
|
||||
```
|
||||
|
||||
Contribution
|
||||
------------
|
||||
|
||||
```shell
|
||||
|
||||
# fork pid/speakingurl on Github
|
||||
$ git clone git@github.com:<YOUR_USER>/speakingurl.git
|
||||
$ cd speakingurl
|
||||
$ npm install
|
||||
# add your stuff
|
||||
# add tests
|
||||
# add example for new feature
|
||||
# add release info to CHANGELOG.md
|
||||
# add description/example to README.md
|
||||
$ gulp
|
||||
$ commit files (speakingurl.min.js,...)
|
||||
# if everything works fine, commit, push to your repository
|
||||
# create pull request
|
||||
```
|
||||
|
||||
Release
|
||||
-------
|
||||
|
||||
```shell
|
||||
$ gulp bumpup --patch # --minor # --major
|
||||
$ gulp
|
||||
$ gulp release
|
||||
```
|
||||
|
||||
Release to RubyGems.org
|
||||
-----------------------
|
||||
|
||||
```shell
|
||||
$ gulp
|
||||
$ gem build speakingurl-rails.gemspec
|
||||
$ gem push speakingurl-rails-x.x.x.gem
|
||||
```
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
- https://tools.ietf.org/html/rfc3986
|
||||
- https://en.wikipedia.org/wiki/Transliteration
|
||||
|
||||
Use in other environments
|
||||
-------------------------
|
||||
|
||||
- [SpeakingURL with AngularJS](https://github.com/zappan/angular-speakingurl)
|
||||
- [SpeakingURL with Meteor](https://github.com/ongoworks/meteor-speakingurl)
|
||||
- [SpeakingURL with Ruby on Rails](https://rubygems.org/gems/speakingurl-rails)
|
||||
|
||||
Ports
|
||||
-----
|
||||
|
||||
- Java https://github.com/Weltraumschaf/speakingurl thanks to[@Weltraumschaf](https://github.com/Weltraumschaf/)
|
||||
|
||||
Credits
|
||||
-------
|
||||
|
||||
- [@dypsilon](https://github.com/dypsilon/)
|
||||
- [@simov](https://github.com/simov/)
|
||||
- [@henrikjoreteg](https://github.com/henrikjoreteg/)
|
||||
|
||||
[License](https://raw.github.com/pid/speakingurl/master/LICENSE)
|
||||
----------------------------------------------------------------
|
||||
|
||||
The BSD 3-Clause License (BSD3)
|
||||
|
||||
Copyright (c) 2013-2017 Sascha Droste pid@posteo.net All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
- Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
19
node_modules/speakingurl/bower.json
generated
vendored
Normal file
19
node_modules/speakingurl/bower.json
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "speakingurl",
|
||||
"version": "14.0.1",
|
||||
"description": "Generate a slug – transliteration with a lot of options",
|
||||
"main": "lib/speakingurl.js",
|
||||
"homepage": "http://pid.github.io/speakingurl/",
|
||||
"bugs": "https://github.com/pid/speakingurl/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/pid/speakingurl.git"
|
||||
},
|
||||
"licenses": [{
|
||||
"type": "BSD",
|
||||
"url": "https://raw.github.com/pid/speakingurl/master/LICENSE"
|
||||
}],
|
||||
"ignore": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
21
node_modules/speakingurl/component.json
generated
vendored
Normal file
21
node_modules/speakingurl/component.json
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "speakingurl",
|
||||
"repo": "pid/speakingurl",
|
||||
"description": "Generate of so called 'static' or 'Clean URL' or 'Pretty URL' or 'nice-looking URL' or 'Speaking URL' or 'user-friendly URL' or 'SEO-friendly URL' or 'slug' from a string.",
|
||||
"version": "14.0.1",
|
||||
"keywords": [
|
||||
"slug",
|
||||
"seo",
|
||||
"url",
|
||||
"speakingurl",
|
||||
"nice url",
|
||||
"static url"
|
||||
],
|
||||
"dependencies": {},
|
||||
"development": {},
|
||||
"license": "BSD",
|
||||
"main": "speakingurl.min.js",
|
||||
"scripts": [
|
||||
"speakingurl.min.js"
|
||||
]
|
||||
}
|
49
node_modules/speakingurl/examples/browser-example.html
generated
vendored
Normal file
49
node_modules/speakingurl/examples/browser-example.html
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<script src="../speakingurl.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SpeakingURL browser example</h1>
|
||||
|
||||
<div id="slug1"></div>
|
||||
<div id="slug2"></div>
|
||||
<div id="slug3"></div>
|
||||
<div id="slug4"></div>
|
||||
<div id="slug5"></div>
|
||||
<div id="slug6"></div>
|
||||
<div id="slug7"></div>
|
||||
<div id="slug8"></div>
|
||||
<div id="slug9"></div>
|
||||
<div id="slug10"></div>
|
||||
<div id="slug11"></div>
|
||||
<div id="slug12"></div>
|
||||
<div id="slug13"></div>
|
||||
<div id="slug14"></div>
|
||||
<div id="slug15"></div>
|
||||
|
||||
<script>
|
||||
document.getElementById("slug1").innerHTML = getSlug("Schöner Titel läßt grüßen!? Bel été !")
|
||||
document.getElementById("slug2").innerHTML = getSlug("Schöner Titel läßt grüßen!? Bel été !", "*");
|
||||
document.getElementById("slug3").innerHTML = getSlug("Schöner Titel läßt grüßen!? Bel été !", { separator: "_" });
|
||||
document.getElementById("slug4").innerHTML = getSlug("Schöner Titel läßt grüßen!? Bel été !", { uric: true });
|
||||
document.getElementById("slug4").innerHTML = getSlug("Schöner Titel läßt grüßen!? Bel été !", { uricNoSlash: true });
|
||||
document.getElementById("slug6").innerHTML = getSlug("Schöner Titel läßt grüßen!? Bel été !", { mark: true });
|
||||
document.getElementById("slug7").innerHTML = getSlug("Schöner Titel läßt grüßen!? Bel été !", { truncate: 20 });
|
||||
document.getElementById("slug8").innerHTML = getSlug("Schöner Titel läßt grüßen!? Bel été !", { maintainCase: true });
|
||||
document.getElementById("slug9").innerHTML = getSlug("Äpfel & Birnen!", { lang: 'de' });
|
||||
document.getElementById("slug10").innerHTML = getSlug('Foo & Bar * Baz', { custom: { '&': ' doo ' }, uric: true });
|
||||
document.getElementById("slug11").innerHTML = getSlug('Foo ♥ Bar');
|
||||
document.getElementById("slug12").innerHTML = getSlug('Foo & Bar | Baz * Doo', { custom: { '*': "Boo" }, mark: true });
|
||||
document.getElementById("slug13").innerHTML = getSlug('C\'est un beau titre qui ne laisse rien à désirer ! ');
|
||||
document.getElementById("slug14").innerHTML = getSlug('မြန်မာစာ သာဓက');
|
||||
document.getElementById("slug15").innerHTML = getSlug('މއދކ ހާދަ ރީތި ދވހކވ !');
|
||||
</script>
|
||||
|
||||
<a href="javascript:document.location='view-source:'+document.location">view source</a>
|
||||
</body>
|
||||
|
||||
</html>
|
115
node_modules/speakingurl/examples/node-example.js
generated
vendored
Normal file
115
node_modules/speakingurl/examples/node-example.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
'use strict';
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
var slug;
|
||||
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !");
|
||||
console.log(slug); // Output: schoener-titel-laesst-gruessen-bel-ete
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", "*");
|
||||
console.log(slug); // Output: schoener*titel*laesst*gruessen*bel*ete
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
separator: "_"
|
||||
});
|
||||
console.log(slug); // Output: schoener_titel_laesst_gruessen_bel_ete
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
uric: true
|
||||
});
|
||||
console.log(slug); // Output: schoener-titel-laesst-gruessen?-bel-ete
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
uricNoSlash: true
|
||||
});
|
||||
console.log(slug); // Output: schoener-titel-laesst-gruessen?-bel-ete
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
mark: true
|
||||
});
|
||||
console.log(slug); // Output: schoener-titel-laesst-gruessen!-bel-ete-!
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
truncate: 20
|
||||
});
|
||||
console.log(slug); // Output: schoener-titel
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
maintainCase: true
|
||||
});
|
||||
console.log(slug); // Output: Schoener-Titel-laesst-gruessen-Bel-ete
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug("Äpfel & Birnen!", {
|
||||
lang: 'de'
|
||||
});
|
||||
console.log(slug); // Output: aepfel-und-birnen
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug('Foo & Bar * Baz', {
|
||||
custom: {
|
||||
'&': ' doo '
|
||||
},
|
||||
uric: true
|
||||
});
|
||||
console.log(slug); // Output: foo-doo-bar-baz
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug('Foo ♥ Bar');
|
||||
console.log(slug); // Output: foo-love-bar
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug('Foo & Bar | (Baz) * Doo', {
|
||||
custom: {
|
||||
'*': "Boo"
|
||||
},
|
||||
mark: true
|
||||
});
|
||||
console.log(slug); // Output: foo-and-bar-or-(baz)-boo-doo
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug('*Foo and Bar or Baz', {
|
||||
custom: {
|
||||
'and': 'UND', // replace word
|
||||
'or': '', // remove word
|
||||
'*': 'star'
|
||||
}
|
||||
});
|
||||
console.log(slug); // Output: starfoo-und-bar-baz
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug('NEXUS4 only $299');
|
||||
console.log(slug); // Output: nexus-4-only-usd-299
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug('NEXUS4 only €299', {
|
||||
maintainCase: true
|
||||
});
|
||||
console.log(slug); // Output: NEXUS-4-only-EUR-299
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug('Foo & Bar ♥ Foo < Bar', {
|
||||
lang: false
|
||||
});
|
||||
console.log(slug); // Output: foo-bar-foo-bar
|
||||
console.log("\n");
|
||||
|
||||
slug = getSlug('မြန်မာစာ သာဓက', {
|
||||
lang: 'my'
|
||||
});
|
||||
console.log(slug); // Output: myanma-thadak
|
||||
console.log('\n');
|
||||
|
||||
slug = getSlug('މިއަދަކީ ހދ ރީތި ދވހކވ', {
|
||||
lang: 'dv'
|
||||
});
|
||||
console.log(slug); // Output: miadhakee hd reethi dvhkv
|
||||
console.log('\n');
|
1
node_modules/speakingurl/index.js
generated
vendored
Normal file
1
node_modules/speakingurl/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./lib/speakingurl');
|
14
node_modules/speakingurl/lib/speakingurl-rails.rb
generated
vendored
Normal file
14
node_modules/speakingurl/lib/speakingurl-rails.rb
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'rails'
|
||||
require 'sprockets/railtie'
|
||||
|
||||
module Speakingurl
|
||||
module Rails
|
||||
class Railtie < ::Rails::Railtie
|
||||
initializer "speakingurl_rails.append_path", :group => :all do |app|
|
||||
speakingurl_path = File.expand_path('../', __FILE__)
|
||||
sprockets_env = app.assets || Sprockets
|
||||
sprockets_env.prepend_path(speakingurl_path.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
1689
node_modules/speakingurl/lib/speakingurl.js
generated
vendored
Normal file
1689
node_modules/speakingurl/lib/speakingurl.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
89
node_modules/speakingurl/package.json
generated
vendored
Normal file
89
node_modules/speakingurl/package.json
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"name": "speakingurl",
|
||||
"version": "14.0.1",
|
||||
"description": "Generate a slug – transliteration with a lot of options",
|
||||
"homepage": "http://pid.github.io/speakingurl/",
|
||||
"github": "http://github.com/pid/speakingurl",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pid/speakingurl.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pid/speakingurl/issues"
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"licenses": [{
|
||||
"type": "BSD",
|
||||
"url": "https://raw.github.com/pid/speakingurl/master/LICENSE"
|
||||
}],
|
||||
"keywords": [
|
||||
"slug",
|
||||
"slugify",
|
||||
"speakingurl",
|
||||
"transliteration",
|
||||
"permalink",
|
||||
"seo",
|
||||
"url",
|
||||
"nice url",
|
||||
"static url",
|
||||
"clean url",
|
||||
"pretty url",
|
||||
"nice looking url",
|
||||
"user friendly url",
|
||||
"seo friendly url"
|
||||
],
|
||||
"categories": [
|
||||
"Utilities",
|
||||
"Parsers & Compilers"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"author": "Sascha Droste <pid@posteo.net> (https://twitter.com/SaschaDroste)",
|
||||
"main": "index",
|
||||
"filename": "speakingurl.min.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.8.8",
|
||||
"gulp-bump": "^2.4.0",
|
||||
"gulp-header": "^1.2.2",
|
||||
"gulp-jsbeautifier": "^2.0.3",
|
||||
"gulp-jshint": "^2.0.0",
|
||||
"gulp-load-plugins": "^1.1.0",
|
||||
"gulp-mocha": "^4.3.1",
|
||||
"gulp-rename": "^1.2.0",
|
||||
"gulp-replace": "^0.6.1",
|
||||
"gulp-uglify": "^3.0.0",
|
||||
"jshint": "^2.8.0",
|
||||
"jshint-stylish": "^2.0.0",
|
||||
"minimist": "^1.1.0",
|
||||
"mocha": "^3.0.2",
|
||||
"should": "^11.1.0"
|
||||
},
|
||||
"jam": {
|
||||
"dependencies": {},
|
||||
"main": "speakingurl.min.js",
|
||||
"shim": {
|
||||
"deps": [],
|
||||
"exports": [
|
||||
"getSlug",
|
||||
"createSlug"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"speakingurl.min.js",
|
||||
"README.md"
|
||||
]
|
||||
},
|
||||
"volo": {
|
||||
"url": "//cdnjs.cloudflare.com/ajax/libs/speakingurl/{version}/speakingurl.min.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"directories": {
|
||||
"example": "examples",
|
||||
"lib": "lib",
|
||||
"test": "test"
|
||||
}
|
||||
}
|
23
node_modules/speakingurl/speakingurl-rails.gemspec
generated
vendored
Normal file
23
node_modules/speakingurl/speakingurl-rails.gemspec
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
require 'json'
|
||||
|
||||
package_path = File.expand_path('../package.json', __FILE__)
|
||||
package_json = JSON.parse(File.read(package_path))
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "speakingurl-rails"
|
||||
s.version = package_json["version"]
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.author = "Sascha Droste"
|
||||
s.metadata = { "contributor" => "Josef Šimánek <https://github.com/simi>" }
|
||||
s.email = ["pid@posteo.net"]
|
||||
s.homepage = "http://pid.github.io/speakingurl/"
|
||||
s.summary = "Speakingurl for Rails asset pipeline"
|
||||
s.description = "Generate a slug – transliteration with a lot of options"
|
||||
s.license = "BSD"
|
||||
|
||||
s.add_dependency "railties", [">= 3.1"]
|
||||
|
||||
s.files = %w(README.md LICENSE lib/speakingurl-rails.rb lib/speakingurl.js)
|
||||
|
||||
s.require_paths = ["lib"]
|
||||
end
|
7
node_modules/speakingurl/speakingurl.min.js
generated
vendored
Normal file
7
node_modules/speakingurl/speakingurl.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/speakingurl/test/mocha.opts
generated
vendored
Normal file
2
node_modules/speakingurl/test/mocha.opts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
--require should
|
||||
--reporter spec
|
111
node_modules/speakingurl/test/test-accent.js
generated
vendored
Normal file
111
node_modules/speakingurl/test/test-accent.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/* global describe,it, before */
|
||||
|
||||
describe('getSlug translate sentence with accent words', function () {
|
||||
'use strict';
|
||||
|
||||
describe('default options', function () {
|
||||
|
||||
var getSlug = require('../lib/speakingurl').createSlug({
|
||||
|
||||
});
|
||||
|
||||
it('single word', function (done) {
|
||||
|
||||
getSlug('Ánhanguera')
|
||||
.should.eql('anhanguera');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('middle of sentence', function (done) {
|
||||
|
||||
getSlug('foo Ánhanguera bar')
|
||||
.should.eql('foo-anhanguera-bar');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('beginning of sentence', function (done) {
|
||||
|
||||
getSlug('Ánhanguera foo bar')
|
||||
.should.eql('anhanguera-foo-bar');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('end of sentence', function (done) {
|
||||
|
||||
getSlug('Ánhanguera fooá')
|
||||
.should.eql('anhanguera-fooa');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('titlecase options', function () {
|
||||
|
||||
var getSlug = require('../lib/speakingurl').createSlug({
|
||||
titleCase: [
|
||||
'a', 'an', 'and', 'as', 'at', 'but',
|
||||
'by', 'en', 'for', 'if', 'in', 'nor',
|
||||
'of', 'on', 'or', 'per', 'the', 'to', 'vs'
|
||||
]
|
||||
});
|
||||
|
||||
it('single word', function (done) {
|
||||
|
||||
getSlug('Ánhanguera')
|
||||
.should.eql('Anhanguera');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('middle of sentence', function (done) {
|
||||
|
||||
getSlug('foo Ánhanguera bar')
|
||||
.should.eql('Foo-Anhanguera-Bar');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('middle of sentence, with exception', function (done) {
|
||||
|
||||
getSlug('foo Ánhanguera And bar')
|
||||
.should.eql('Foo-Anhanguera-and-Bar');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('beginning of sentence', function (done) {
|
||||
|
||||
getSlug('Ánhanguera foo Ánhanguera')
|
||||
.should.eql('Anhanguera-Foo-Anhanguera');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('beginning of sentence, with exception', function (done) {
|
||||
|
||||
getSlug('Ánhanguera and Ánhanguera')
|
||||
.should.eql('Anhanguera-and-Anhanguera');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('end of sentence', function (done) {
|
||||
|
||||
getSlug('Ánhanguera foo bará')
|
||||
.should.eql('Anhanguera-Foo-Bara');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('end of sentence, with exception', function (done) {
|
||||
|
||||
getSlug('Ánhanguera foo and bará')
|
||||
.should.eql('Anhanguera-Foo-and-Bara');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
18
node_modules/speakingurl/test/test-arabic.js
generated
vendored
Normal file
18
node_modules/speakingurl/test/test-arabic.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug translate arabic letters', function () {
|
||||
'use strict';
|
||||
|
||||
it('should be ', function (done) {
|
||||
|
||||
getSlug('بشس تاقفغقف - ت ب ي ق', {
|
||||
lang: 'ar'
|
||||
})
|
||||
.should.eql('bshs-taqfghqf-t-b-y-q');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
205
node_modules/speakingurl/test/test-burmese.js
generated
vendored
Normal file
205
node_modules/speakingurl/test/test-burmese.js
generated
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug translate burmese letters', function () {
|
||||
'use strict';
|
||||
|
||||
it('one consonant', function (done) {
|
||||
getSlug('မ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('m');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('one independent vowel', function (done) {
|
||||
getSlug('ဪ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('aw');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('one consonant with one vowel', function (done) {
|
||||
|
||||
getSlug('ကာ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('ka');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('one consonant and multiple vowels', function (done) {
|
||||
|
||||
getSlug('ကော', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('kaw');
|
||||
|
||||
getSlug('ကော်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('kaw');
|
||||
|
||||
getSlug('ကွဲ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('kwe');
|
||||
|
||||
getSlug('ပေါ်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('paw');
|
||||
|
||||
getSlug('ပို', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('po');
|
||||
|
||||
getSlug('ကူ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('ku');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('one consonant and multiple medials', function (done) {
|
||||
getSlug('မျှ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('myah');
|
||||
|
||||
getSlug('ကြွ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('kyw');
|
||||
|
||||
getSlug('လွှ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('lwh');
|
||||
|
||||
getSlug('မြွှ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('mywh');
|
||||
|
||||
getSlug('ကုံ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('kon');
|
||||
|
||||
getSlug('ဘွိုင်း', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('bawaing');
|
||||
|
||||
getSlug('လျှင်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('lyahin');
|
||||
done();
|
||||
});
|
||||
|
||||
it('one pali word', function (done) {
|
||||
getSlug('စ္စ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('ss');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('one single consonant and one consonant with asat', function (done) {
|
||||
getSlug('ကက်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('ket');
|
||||
|
||||
getSlug('ပိုက်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('paik');
|
||||
|
||||
getSlug('ကောက်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('kauk');
|
||||
done();
|
||||
});
|
||||
|
||||
it('pali asat and tone marks', function (done) {
|
||||
getSlug('ကျွန်ုပ်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('kyawnub');
|
||||
|
||||
getSlug('ပစ္စည်း', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('pssi');
|
||||
|
||||
getSlug('တက္ကသိုလ်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('tkkthol');
|
||||
|
||||
getSlug('သဏ္ဍာန်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('thnadan');
|
||||
getSlug('လိမ္မော်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('limmaw');
|
||||
getSlug('စက္ကူ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('skku');
|
||||
getSlug('ဘဏ္ဍာ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('banada');
|
||||
getSlug('မင်္ဂလာ', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('mingla');
|
||||
done();
|
||||
});
|
||||
|
||||
it('simple sentence with spaces and tone marks', function (done) {
|
||||
getSlug('မြန်မာပြည် ကို တို့ချစ်သည်၊ တို့တိုင်းတို့ပြည်', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('myanmapyi-ko-tokhyaitthi-totaingtopyi');
|
||||
|
||||
getSlug('သတ္တဝါတွေ ကျန်းမာပါစေ။', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('thttwatwe-kyaanmapase');
|
||||
|
||||
getSlug('မြန်မာ သာဓက', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('myanma-thadak');
|
||||
done();
|
||||
});
|
||||
|
||||
it('complex sentences with combinations of consonants, vowels and diatrics', function (done) {
|
||||
getSlug('ဘင်္ဂလား ပင်လယ်အော် တွင် ယနေ့ နေသာသည်။', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('baingla-pinleaaw-twin-yne-nethathi');
|
||||
|
||||
getSlug('ဗုဒ္ဓဘာသာ မြန်မာလူမျိုး', {
|
||||
lang: 'my'
|
||||
})
|
||||
.should.eql('buddabaatha-myanmalumyao');
|
||||
done();
|
||||
});
|
||||
});
|
337
node_modules/speakingurl/test/test-create.js
generated
vendored
Normal file
337
node_modules/speakingurl/test/test-create.js
generated
vendored
Normal file
@@ -0,0 +1,337 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug create', function () {
|
||||
'use strict';
|
||||
|
||||
it('with symbols', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
lang: 'en',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
});
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar')
|
||||
.should.eql('foo-(love)-;-baz=bar');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('without options', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug();
|
||||
|
||||
getSlug('Foo Bar Baz')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with empty options', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({});
|
||||
|
||||
getSlug('Foo Bar Baz')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with maintainCase', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
maintainCase: true
|
||||
});
|
||||
|
||||
getSlug('Foo Bar Baz')
|
||||
.should.eql('Foo-Bar-Baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with uric', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
uric: true
|
||||
});
|
||||
|
||||
getSlug(' :80:/Foo/Bar/Baz:Foo')
|
||||
.should.eql(':80:/foo/bar/baz:foo');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with uricNoSlash', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
uricNoSlash: true
|
||||
});
|
||||
|
||||
getSlug('Foo/ Bar= Baz')
|
||||
.should.eql('foo-bar=-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with mark', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
mark: true
|
||||
});
|
||||
|
||||
getSlug('Foo* Bar Baz')
|
||||
.should.eql('foo*-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with truncate', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
truncate: 15
|
||||
});
|
||||
|
||||
getSlug('Foo* Foobar FooBarBaz')
|
||||
.should.eql('foo-foobar');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with separator', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
separator: '_'
|
||||
});
|
||||
|
||||
getSlug('Foo* Foobar FooBarBaz')
|
||||
.should.eql('foo_foobar_foobarbaz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with mark and maintainCase', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
mark: true,
|
||||
maintainCase: true
|
||||
});
|
||||
|
||||
getSlug('Foo* Bar Baz')
|
||||
.should.eql('Foo*-Bar-Baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with custom chars replacement', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
custom: {
|
||||
'*': 'o'
|
||||
}
|
||||
});
|
||||
|
||||
getSlug('xyl*ph*n')
|
||||
.should.eql('xylophon');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with custom chars leet replacement', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
custom: {
|
||||
'a': '4',
|
||||
'b': '8',
|
||||
'e': '3',
|
||||
'g': '6',
|
||||
'l': '1',
|
||||
'o': '0',
|
||||
's': '5',
|
||||
't': '7'
|
||||
},
|
||||
lang: false
|
||||
});
|
||||
|
||||
getSlug('apbpepgplpopspt')
|
||||
.should.eql('4p8p3p6p1p0p5p7');
|
||||
getSlug('papbpepgplpopsptp')
|
||||
.should.eql('p4p8p3p6p1p0p5p7p');
|
||||
getSlug('qabqegqloqst')
|
||||
.should.eql('q48q36q10q57');
|
||||
getSlug('abeglost')
|
||||
.should.eql('48361057');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with custom chars replacement with not allowed target char', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
custom: {
|
||||
'o': '*'
|
||||
}
|
||||
});
|
||||
|
||||
getSlug('xylophon')
|
||||
.should.eql('xyl-ph-n');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with custom chars replacement with allowed target char, option mark', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
custom: {
|
||||
'o': '*'
|
||||
},
|
||||
mark: true
|
||||
});
|
||||
|
||||
getSlug('xylophon')
|
||||
.should.eql('xyl*ph*n');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with custom chars replacement with option mark', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
custom: {
|
||||
'*': 'o'
|
||||
},
|
||||
mark: true
|
||||
});
|
||||
|
||||
getSlug('xyl*ph*n')
|
||||
.should.eql('xylophon');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with custom char to string replacement', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
custom: {
|
||||
'*': 'STAR',
|
||||
'q': 'qqq',
|
||||
'and': '',
|
||||
'or': ''
|
||||
}
|
||||
});
|
||||
|
||||
getSlug('xyl*ph*n')
|
||||
.should.eql('xylstarphstarn');
|
||||
getSlug('quack')
|
||||
.should.eql('qqquack');
|
||||
getSlug('Foo and Bar or Baz')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with custom string replacement', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
custom: {
|
||||
'and': 'und',
|
||||
'or': 'oder',
|
||||
'*': ' and '
|
||||
}
|
||||
});
|
||||
|
||||
getSlug('bus and train')
|
||||
.should.eql('bus-und-train');
|
||||
getSlug('bus or train')
|
||||
.should.eql('bus-oder-train');
|
||||
getSlug('busandtrain')
|
||||
.should.eql('busandtrain');
|
||||
getSlug('busortrain')
|
||||
.should.eql('busortrain');
|
||||
getSlug('bus*train')
|
||||
.should.eql('bus-and-train');
|
||||
|
||||
getSlug('bus and train bus and train')
|
||||
.should.eql('bus-und-train-bus-und-train');
|
||||
getSlug('bus or train bus or train')
|
||||
.should.eql('bus-oder-train-bus-oder-train');
|
||||
getSlug('busandtrain busandtrain')
|
||||
.should.eql('busandtrain-busandtrain');
|
||||
getSlug('busortrain busortrain')
|
||||
.should.eql('busortrain-busortrain');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with custom string replacement with option mark', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
custom: {
|
||||
'*': 'STAR',
|
||||
'q': 'qqq',
|
||||
'z': ''
|
||||
},
|
||||
mark: true
|
||||
});
|
||||
|
||||
getSlug('xyl*ph*n')
|
||||
.should.eql('xylstarphstarn');
|
||||
getSlug('qxxx')
|
||||
.should.eql('qqqxxx');
|
||||
getSlug('xxxqxxx')
|
||||
.should.eql('xxxqqqxxx');
|
||||
getSlug('qqq')
|
||||
.should.eql('qqqqqqqqq');
|
||||
getSlug('*q*')
|
||||
.should.eql('starqqqstar');
|
||||
getSlug('zoo')
|
||||
.should.eql('oo');
|
||||
getSlug('zooz')
|
||||
.should.eql('oo');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('with custom string replacement with option maintainCase', function (done) {
|
||||
|
||||
var getSlug = require('../lib/speakingurl')
|
||||
.createSlug({
|
||||
custom: {
|
||||
'*': 'STAR',
|
||||
'q': 'qqq',
|
||||
},
|
||||
maintainCase: true
|
||||
});
|
||||
|
||||
getSlug('xyl*ph*n')
|
||||
.should.eql('xylSTARphSTARn');
|
||||
getSlug('qXXX')
|
||||
.should.eql('qqqXXX');
|
||||
getSlug('qqq')
|
||||
.should.eql('qqqqqqqqq');
|
||||
getSlug('*q*')
|
||||
.should.eql('STARqqqSTAR');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
98
node_modules/speakingurl/test/test-custom.js
generated
vendored
Normal file
98
node_modules/speakingurl/test/test-custom.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug with custom replacement', function () {
|
||||
'use strict';
|
||||
|
||||
it('should be transliterated', function (done) {
|
||||
|
||||
getSlug('буу', {
|
||||
lang: false,
|
||||
custom: {
|
||||
'б': 'б',
|
||||
'у': 'у'
|
||||
}
|
||||
})
|
||||
.should.eql('буу');
|
||||
|
||||
getSlug('[nodejs]', {
|
||||
custom: {
|
||||
'[': '[',
|
||||
']': ']'
|
||||
}
|
||||
})
|
||||
.should.eql('[nodejs]');
|
||||
|
||||
getSlug('[Äpfel]', {
|
||||
custom: {
|
||||
'[': '[',
|
||||
']': ']'
|
||||
}
|
||||
})
|
||||
.should.eql('[aepfel]');
|
||||
|
||||
getSlug('[Äpfel]', {
|
||||
lang: false,
|
||||
custom: {
|
||||
'[': '[',
|
||||
']': ']'
|
||||
}
|
||||
})
|
||||
.should.eql('[aepfel]');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should be extended with allowed chars', function (done) {
|
||||
|
||||
getSlug('буу', {
|
||||
custom: ['б', 'у']
|
||||
})
|
||||
.should.eql('буу');
|
||||
|
||||
getSlug('[Knöpfe]', {
|
||||
custom: ['[', ']']
|
||||
})
|
||||
.should.eql('[knoepfe]');
|
||||
|
||||
getSlug('[Knöpfe & Ösen]', {
|
||||
custom: ['[', ']']
|
||||
})
|
||||
.should.eql('[knoepfe-and-oesen]');
|
||||
|
||||
getSlug('[Knöpfe & Ösen]', {
|
||||
custom: ['[', ']'],
|
||||
lang: 'de'
|
||||
})
|
||||
.should.eql('[knoepfe-und-oesen]');
|
||||
|
||||
getSlug('[Knöpfe]', {
|
||||
maintainCase: true,
|
||||
custom: ['[', ']']
|
||||
})
|
||||
.should.eql('[Knoepfe]');
|
||||
|
||||
getSlug('[Knöpfe haben Löcher]', {
|
||||
titleCase: true,
|
||||
custom: ['[', ']']
|
||||
})
|
||||
.should.eql('[Knoepfe-Haben-Loecher]');
|
||||
|
||||
getSlug('[knöpfe haben runde löcher]', {
|
||||
titleCase: ['haben', 'runde'],
|
||||
custom: ['[', ']']
|
||||
})
|
||||
.should.eql('[Knoepfe-haben-runde-Loecher]');
|
||||
|
||||
getSlug('[knöpfe haben runde löcher]', {
|
||||
titleCase: ['haben', 'runde'],
|
||||
maintainCase: true,
|
||||
custom: ['[', ']']
|
||||
})
|
||||
.should.eql('[Knoepfe-haben-runde-Loecher]');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
16
node_modules/speakingurl/test/test-cyrillic.js
generated
vendored
Normal file
16
node_modules/speakingurl/test/test-cyrillic.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug translate cyrillic letters', function () {
|
||||
'use strict';
|
||||
|
||||
it('should be ', function (done) {
|
||||
|
||||
getSlug('Пью')
|
||||
.should.eql('pyu');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
123
node_modules/speakingurl/test/test-defaults.js
generated
vendored
Normal file
123
node_modules/speakingurl/test/test-defaults.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug defaults', function () {
|
||||
'use strict';
|
||||
|
||||
it('should replace whitespaces with separator', function (done) {
|
||||
|
||||
getSlug('foo bar baz')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should remove trailing space if any', function (done) {
|
||||
|
||||
getSlug(' foo bar baz ')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should remove multiple whitespaces', function (done) {
|
||||
|
||||
getSlug(' foo bar baz FOO BAR BAZ ')
|
||||
.should.eql('foo-bar-baz-foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should remove multiple separators at start and end', function (done) {
|
||||
|
||||
getSlug('-foo- bar -baz-')
|
||||
.should.eql('foo-bar-baz');
|
||||
getSlug('--foo- bar -baz---')
|
||||
.should.eql('foo-bar-baz');
|
||||
getSlug('---foo- bar -baz---')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should remove multple separators', function (done) {
|
||||
|
||||
getSlug('foo- bar -baz')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should remove non-base64 characters', function (done) {
|
||||
|
||||
var nonBase64 = ['[', ']', ',', '*', '+', '~', '.', '(', ')', '\'', '"', '!', ':', '@'];
|
||||
|
||||
for (var i = 0; i < nonBase64.length; i++) {
|
||||
getSlug("foo " + nonBase64[i] + " bar baz")
|
||||
.should.eql("foo-bar-baz");
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should remove trailing separator', function (done) {
|
||||
|
||||
getSlug('C\'est un beau titre qui ne laisse rien à désirer ! ')
|
||||
.should.eql(
|
||||
'c-est-un-beau-titre-qui-ne-laisse-rien-a-desirer');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should handle whitespace after symbol', function (done) {
|
||||
|
||||
getSlug('∆299')
|
||||
.should.eql('delta-299');
|
||||
getSlug('∆world')
|
||||
.should.eql('delta-world');
|
||||
getSlug('∆-299')
|
||||
.should.eql('delta-299');
|
||||
getSlug('∆-world')
|
||||
.should.eql('delta-world');
|
||||
|
||||
getSlug('(∆)299')
|
||||
.should.eql('delta-299');
|
||||
getSlug('(∆)299', {
|
||||
mark: true
|
||||
})
|
||||
.should.eql('(delta)299');
|
||||
|
||||
getSlug('∆299')
|
||||
.should.eql('delta-299');
|
||||
getSlug('∆world')
|
||||
.should.eql('delta-world');
|
||||
|
||||
getSlug('Hello∆299')
|
||||
.should.eql('hello-delta-299');
|
||||
getSlug('299∆Hello')
|
||||
.should.eql('299-delta-hello');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not fail if symbol at the end', function (done) {
|
||||
|
||||
getSlug('test &')
|
||||
.should.eql('test-and');
|
||||
getSlug('test & ')
|
||||
.should.eql('test-and');
|
||||
getSlug('test &', '_')
|
||||
.should.eql('test_and');
|
||||
getSlug('test ♥')
|
||||
.should.eql('test-love');
|
||||
getSlug('test ♥ ')
|
||||
.should.eql('test-love');
|
||||
getSlug('test ♥ ')
|
||||
.should.eql('test-love');
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
|
||||
});
|
18
node_modules/speakingurl/test/test-dhivehi.js
generated
vendored
Normal file
18
node_modules/speakingurl/test/test-dhivehi.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug translate dhivehi letters', function () {
|
||||
'use strict';
|
||||
|
||||
it('should be ', function (done) {
|
||||
|
||||
getSlug('މއދކ ވ ރ ށ ރީތި', {
|
||||
lang: 'dv'
|
||||
})
|
||||
.should.eql('madhk-v-r-sh-reethi');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
18
node_modules/speakingurl/test/test-georgien.js
generated
vendored
Normal file
18
node_modules/speakingurl/test/test-georgien.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug translate georgien letters', function () {
|
||||
'use strict';
|
||||
|
||||
it('should be ', function (done) {
|
||||
|
||||
getSlug('აბ', {
|
||||
lang: 'ge'
|
||||
})
|
||||
.should.eql('ab');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
33
node_modules/speakingurl/test/test-hungarian.js
generated
vendored
Normal file
33
node_modules/speakingurl/test/test-hungarian.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug translate hungarian letters', function () {
|
||||
'use strict';
|
||||
|
||||
it('umlaut should be single letter transliteration', function (done) {
|
||||
|
||||
getSlug('AÁEÉIÍOÓÖŐUÚÜŰ', {
|
||||
lang: 'hu'
|
||||
})
|
||||
.should.eql('aaeeiioooouuuu');
|
||||
|
||||
getSlug('aáeéiíoóöőuúüű', {
|
||||
lang: 'hu'
|
||||
})
|
||||
.should.eql('aaeeiioooouuuu');
|
||||
|
||||
getSlug('AÁEÉIÍOÓÖŐUÚÜŰ AÁEÉIÍOÓÖŐUÚÜŰ', {
|
||||
lang: 'hu'
|
||||
})
|
||||
.should.eql('aaeeiioooouuuu-aaeeiioooouuuu');
|
||||
|
||||
getSlug('aáeéiíoóöőuúüű aáeéiíoóöőuúüű', {
|
||||
lang: 'hu'
|
||||
})
|
||||
.should.eql('aaeeiioooouuuu-aaeeiioooouuuu');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
473
node_modules/speakingurl/test/test-lang.js
generated
vendored
Normal file
473
node_modules/speakingurl/test/test-lang.js
generated
vendored
Normal file
@@ -0,0 +1,473 @@
|
||||
/* global describe,it */
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug symbols', function () {
|
||||
'use strict';
|
||||
|
||||
it('should convert symbols', function (done) {
|
||||
|
||||
getSlug('Foo & Bar | Baz')
|
||||
.should.eql('foo-and-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'cs'
|
||||
})
|
||||
.should.eql('foo-a-bar-nebo-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'en'
|
||||
})
|
||||
.should.eql('foo-and-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'de'
|
||||
})
|
||||
.should.eql('foo-und-bar-oder-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'fr'
|
||||
})
|
||||
.should.eql('foo-et-bar-ou-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'es'
|
||||
})
|
||||
.should.eql('foo-y-bar-u-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'ru'
|
||||
})
|
||||
.should.eql('foo-i-bar-ili-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'ro'
|
||||
})
|
||||
.should.eql('foo-si-bar-sau-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'sk'
|
||||
})
|
||||
.should.eql('foo-a-bar-alebo-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('shouldn\'t convert symbols', function (done) {
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'en',
|
||||
symbols: false
|
||||
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'de',
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'fr',
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'es',
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'ru',
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'cs',
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'sk',
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not convert symbols with uric flag true', function (done) {
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'en',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'de',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-oder-baz');
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'fr',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-ou-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'es',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-u-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'ru',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-ili-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'cs',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-nebo-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'sk',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-alebo-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not convert symbols with uricNoSlash flag true', function (done) {
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'en',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'de',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-oder-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'fr',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-ou-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'es',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-u-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'ru',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-ili-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'cs',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-nebo-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'sk',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-alebo-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not convert symbols with mark flag true', function (done) {
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'en',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'de',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'fr',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'es',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'ru',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'cs',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'sk',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
|
||||
it('should convert symbols with flags true', function (done) {
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'en',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(love)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'de',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(liebe)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'fr',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(amour)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'es',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(amor)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'ru',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(lubov)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'cs',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(laska)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'sk',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(laska)-;-baz=bar');
|
||||
|
||||
getSlug(' Sch(* )ner (♥)Ti♥tel ♥läßt grüßen!? Bel♥♥ été !', {
|
||||
lang: 'en',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true,
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql(
|
||||
'Sch(*-)ner-(love)Ti-love-tel-love-laesst-gruessen!?-Bel-love-love-ete-!'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should replace symbols (de)', function (done) {
|
||||
|
||||
getSlug('Äpfel & Birnen', {
|
||||
lang: 'de'
|
||||
})
|
||||
.should.eql('aepfel-und-birnen');
|
||||
|
||||
getSlug('ÄÖÜäöüß', {
|
||||
lang: 'de',
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('AeOeUeaeoeuess');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should replace chars by cs language standards', function (done) {
|
||||
|
||||
getSlug(
|
||||
'AaÁáBbCcČčDdĎďEeÉéĚěFfGgHhChchIiÍíJjKkLlMmNnŇňOoÓóPpQqRrŘřSsŠšTtŤťUuÚúŮůVvWwXxYyÝýZzŽž', {
|
||||
lang: 'cs'
|
||||
})
|
||||
.should.eql(
|
||||
'aaaabbccccddddeeeeeeffgghhchchiiiijjkkllmmnnnnooooppqqrrrrssssttttuuuuuuvvwwxxyyyyzzzz'
|
||||
);
|
||||
|
||||
getSlug(
|
||||
'AaÁáBbCcČčDdĎďEeÉéĚěFfGgHhChchIiÍíJjKkLlMmNnŇňOoÓóPpQqRrŘřSsŠšTtŤťUuÚúŮůVvWwXxYyÝýZzŽž', {
|
||||
lang: 'cs',
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql(
|
||||
'AaAaBbCcCcDdDdEeEeEeFfGgHhChchIiIiJjKkLlMmNnNnOoOoPpQqRrRrSsSsTtTtUuUuUuVvWwXxYyYyZzZz'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should replace chars by se language standards', function (done) {
|
||||
|
||||
getSlug(
|
||||
'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzÅåÄäÖö', {
|
||||
lang: 'sv',
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql(
|
||||
'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaAaOo'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should replace chars by fi language standards', function (done) {
|
||||
|
||||
getSlug(
|
||||
'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzÅåÄäÖö', {
|
||||
lang: 'fi',
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql(
|
||||
'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaAaOo'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should replace chars by sk language standards', function (done) {
|
||||
|
||||
getSlug(
|
||||
'AaÁaÄäBbCcČčDdĎďDzdzDždžEeÉéFfGgHhChchIiÍíJjKkLlĹ弾MmNnŇňOoÓóÔôPpQqRrŔŕSsŠšTtŤťUuÚúVvWwXxYyÝýZzŽž', {
|
||||
lang: 'sk'
|
||||
})
|
||||
.should.eql(
|
||||
'aaaaaabbccccdddddzdzdzdzeeeeffgghhchchiiiijjkkllllllmmnnnnooooooppqqrrrrssssttttuuuuvvwwxxyyyyzzzz'
|
||||
);
|
||||
|
||||
getSlug(
|
||||
'AaÁaÄäBbCcČčDdĎďDzdzDždžEeÉéFfGgHhChchIiÍíJjKkLlĹ弾MmNnŇňOoÓóÔôPpQqRrŔŕSsŠšTtŤťUuÚúVvWwXxYyÝýZzŽž', {
|
||||
lang: 'sk',
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql(
|
||||
'AaAaAaBbCcCcDdDdDzdzDzdzEeEeFfGgHhChchIiIiJjKkLlLlLlMmNnNnOoOoOoPpQqRrRrSsSsTtTtUuUuVvWwXxYyYyZzZz'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should ignore not available language param', function (done) {
|
||||
|
||||
getSlug('Äpfel & Birnen', {
|
||||
lang: 'xx'
|
||||
})
|
||||
.should.eql('aepfel-and-birnen');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should convert currency symbols to lowercase', function (done) {
|
||||
|
||||
getSlug('NEXUS4 only €199!', {
|
||||
maintainCase: false
|
||||
})
|
||||
.should.eql('nexus4-only-eur199');
|
||||
|
||||
getSlug('NEXUS4 only €299.93', {
|
||||
maintainCase: false
|
||||
})
|
||||
.should.eql('nexus4-only-eur299-93');
|
||||
|
||||
getSlug('NEXUS4 only 円399.73', {
|
||||
maintainCase: false
|
||||
})
|
||||
.should.eql('nexus4-only-yen399-73');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should convert currency symbols to uppercase', function (done) {
|
||||
|
||||
getSlug('NEXUS4 only €199!', {
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('NEXUS4-only-EUR199');
|
||||
|
||||
getSlug('NEXUS4 only €299.93', {
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('NEXUS4-only-EUR299-93');
|
||||
|
||||
getSlug('NEXUS4 only 円399.73', {
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('NEXUS4-only-YEN399-73');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
304
node_modules/speakingurl/test/test-language.js
generated
vendored
Normal file
304
node_modules/speakingurl/test/test-language.js
generated
vendored
Normal file
@@ -0,0 +1,304 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug languages', function () {
|
||||
'use strict';
|
||||
|
||||
it('should replace language specific symbols', function (done) {
|
||||
|
||||
var symbolMap = {
|
||||
'ar': {
|
||||
'∆': 'delta',
|
||||
'∞': 'la-nihaya',
|
||||
'♥': 'hob',
|
||||
'&': 'wa',
|
||||
'|': 'aw',
|
||||
'<': 'aqal-men',
|
||||
'>': 'akbar-men',
|
||||
'∑': 'majmou',
|
||||
'¤': 'omla'
|
||||
},
|
||||
|
||||
'cs': {
|
||||
'∆': 'delta',
|
||||
'∞': 'nekonecno',
|
||||
'♥': 'laska',
|
||||
'&': 'a',
|
||||
'|': 'nebo',
|
||||
'<': 'mensi nez',
|
||||
'>': 'vetsi nez',
|
||||
'∑': 'soucet',
|
||||
'¤': 'mena'
|
||||
},
|
||||
|
||||
'de': {
|
||||
'∆': 'delta',
|
||||
'∞': 'unendlich',
|
||||
'♥': 'Liebe',
|
||||
'&': 'und',
|
||||
'|': 'oder',
|
||||
'<': 'kleiner als',
|
||||
'>': 'groesser als',
|
||||
'∑': 'Summe von',
|
||||
'¤': 'Waehrung'
|
||||
},
|
||||
|
||||
'en': {
|
||||
'∆': 'delta',
|
||||
'∞': 'infinity',
|
||||
'♥': 'love',
|
||||
'&': 'and',
|
||||
'|': 'or',
|
||||
'<': 'less than',
|
||||
'>': 'greater than',
|
||||
'∑': 'sum',
|
||||
'¤': 'currency'
|
||||
},
|
||||
|
||||
'es': {
|
||||
'∆': 'delta',
|
||||
'∞': 'infinito',
|
||||
'♥': 'amor',
|
||||
'&': 'y',
|
||||
'|': 'u',
|
||||
'<': 'menos que',
|
||||
'>': 'mas que',
|
||||
'∑': 'suma de los',
|
||||
'¤': 'moneda'
|
||||
},
|
||||
|
||||
'fr': {
|
||||
'∆': 'delta',
|
||||
'∞': 'infiniment',
|
||||
'♥': 'Amour',
|
||||
'&': 'et',
|
||||
'|': 'ou',
|
||||
'<': 'moins que',
|
||||
'>': 'superieure a',
|
||||
'∑': 'somme des',
|
||||
'¤': 'monnaie'
|
||||
},
|
||||
|
||||
'hu': {
|
||||
'∆': 'delta',
|
||||
'∞': 'vegtelen',
|
||||
'♥': 'szerelem',
|
||||
'&': 'es',
|
||||
'|': 'vagy',
|
||||
'<': 'kisebb mint',
|
||||
'>': 'nagyobb mint',
|
||||
'∑': 'szumma',
|
||||
'¤': 'penznem'
|
||||
},
|
||||
|
||||
'my': {
|
||||
'∆': 'kwahkhyaet',
|
||||
'∞': 'asaonasme',
|
||||
'♥': 'akhyait',
|
||||
'&': 'nhin',
|
||||
'|': 'tho',
|
||||
'<': 'ngethaw',
|
||||
'>': 'kyithaw',
|
||||
'∑': 'paungld',
|
||||
'¤': 'ngwekye'
|
||||
},
|
||||
|
||||
'nl': {
|
||||
'∆': 'delta',
|
||||
'∞': 'oneindig',
|
||||
'♥': 'liefde',
|
||||
'&': 'en',
|
||||
'|': 'of',
|
||||
'<': 'kleiner dan',
|
||||
'>': 'groter dan',
|
||||
'∑': 'som',
|
||||
'¤': 'valuta'
|
||||
},
|
||||
|
||||
'it': {
|
||||
'∆': 'delta',
|
||||
'∞': 'infinito',
|
||||
'♥': 'amore',
|
||||
'&': 'e',
|
||||
'|': 'o',
|
||||
'<': 'minore di',
|
||||
'>': 'maggiore di',
|
||||
'∑': 'somma',
|
||||
'¤': 'moneta'
|
||||
},
|
||||
|
||||
'pl': {
|
||||
'∆': 'delta',
|
||||
'∞': 'nieskonczonosc',
|
||||
'♥': 'milosc',
|
||||
'&': 'i',
|
||||
'|': 'lub',
|
||||
'<': 'mniejsze niz',
|
||||
'>': 'wieksze niz',
|
||||
'∑': 'suma',
|
||||
'¤': 'waluta'
|
||||
},
|
||||
|
||||
'pt': {
|
||||
'∆': 'delta',
|
||||
'∞': 'infinito',
|
||||
'♥': 'amor',
|
||||
'&': 'e',
|
||||
'|': 'ou',
|
||||
'<': 'menor que',
|
||||
'>': 'maior que',
|
||||
'∑': 'soma',
|
||||
'¤': 'moeda'
|
||||
},
|
||||
|
||||
'ru': {
|
||||
'∆': 'delta',
|
||||
'∞': 'beskonechno',
|
||||
'♥': 'lubov',
|
||||
'&': 'i',
|
||||
'|': 'ili',
|
||||
'<': 'menshe',
|
||||
'>': 'bolshe',
|
||||
'∑': 'summa',
|
||||
'¤': 'valjuta'
|
||||
},
|
||||
|
||||
'sk': {
|
||||
'∆': 'delta',
|
||||
'∞': 'nekonecno',
|
||||
'♥': 'laska',
|
||||
'&': 'a',
|
||||
'|': 'alebo',
|
||||
'<': 'menej ako',
|
||||
'>': 'viac ako',
|
||||
'∑': 'sucet',
|
||||
'¤': 'mena'
|
||||
},
|
||||
|
||||
'tr': {
|
||||
'∆': 'delta',
|
||||
'∞': 'sonsuzluk',
|
||||
'♥': 'ask',
|
||||
'&': 've',
|
||||
'|': 'veya',
|
||||
'<': 'kucuktur',
|
||||
'>': 'buyuktur',
|
||||
'∑': 'toplam',
|
||||
'¤': 'para birimi'
|
||||
},
|
||||
|
||||
'vn': {
|
||||
'∆': 'delta',
|
||||
'∞': 'vo cuc',
|
||||
'♥': 'yeu',
|
||||
'&': 'va',
|
||||
'|': 'hoac',
|
||||
'<': 'nho hon',
|
||||
'>': 'lon hon',
|
||||
'∑': 'tong',
|
||||
'¤': 'tien te'
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Object.keys(symbolMap)
|
||||
.forEach(function (l) {
|
||||
|
||||
// console.log('\ncheck language: ' + l);
|
||||
|
||||
Object.keys(symbolMap[l])
|
||||
.forEach(function (s) {
|
||||
|
||||
var k = symbolMap[l][s];
|
||||
|
||||
// console.log('check symbol: ' + s);
|
||||
|
||||
getSlug('Foo ' + s + ' Bar', {
|
||||
lang: l,
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('Foo-' + getSlug(k, {
|
||||
maintainCase: true
|
||||
}) + '-Bar');
|
||||
|
||||
getSlug('Foo ' + s + ' Bar', {
|
||||
lang: l
|
||||
})
|
||||
.should.eql('foo-' + getSlug(k) + '-bar');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
getSlug('EN Foo & Bar ')
|
||||
.should.eql('en-foo-and-bar');
|
||||
|
||||
getSlug('EN Foo & Bar ', {
|
||||
lang: "en"
|
||||
})
|
||||
.should.eql('en-foo-and-bar');
|
||||
|
||||
getSlug('de Foo & Bar ', {
|
||||
lang: "de"
|
||||
})
|
||||
.should.eql('de-foo-und-bar');
|
||||
|
||||
getSlug('True Foo & Bar ', {
|
||||
lang: true
|
||||
})
|
||||
.should.eql('true-foo-and-bar');
|
||||
|
||||
getSlug('False Foo & Bar ', {
|
||||
lang: false
|
||||
})
|
||||
.should.eql('false-foo-bar');
|
||||
|
||||
getSlug('False Foo & Bar ', {
|
||||
lang: false,
|
||||
symbols: true
|
||||
})
|
||||
.should.eql('false-foo-bar');
|
||||
|
||||
getSlug('xx Foo & Bar ', {
|
||||
lang: "xx"
|
||||
})
|
||||
.should.eql('xx-foo-and-bar');
|
||||
|
||||
getSlug('obj Foo & Bar ', {
|
||||
lang: {}
|
||||
})
|
||||
.should.eql('obj-foo-and-bar');
|
||||
|
||||
getSlug('array Foo & Bar ', {
|
||||
lang: []
|
||||
})
|
||||
.should.eql('array-foo-and-bar');
|
||||
|
||||
getSlug('array Foo & Bar ', {
|
||||
lang: [],
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('array-foo-bar');
|
||||
|
||||
getSlug('null Foo & Bar ', {
|
||||
lang: null
|
||||
})
|
||||
.should.eql('null-foo-and-bar');
|
||||
|
||||
getSlug('null Foo & Bar ', {
|
||||
lang: null,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('null-foo-bar');
|
||||
|
||||
getSlug('null Foo & Bar ', {
|
||||
lang: null,
|
||||
symbols: true
|
||||
})
|
||||
.should.eql('null-foo-and-bar');
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
});
|
32
node_modules/speakingurl/test/test-maintaincase.js
generated
vendored
Normal file
32
node_modules/speakingurl/test/test-maintaincase.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug maintainCase', function () {
|
||||
'use strict';
|
||||
|
||||
it('should maintain case characters', function (done) {
|
||||
|
||||
getSlug('Foo, Bar Baz', {
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('Foo-Bar-Baz');
|
||||
|
||||
getSlug('Foo- Bar Baz', {
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('Foo-Bar-Baz');
|
||||
|
||||
getSlug('Foo] Bar Baz', {
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('Foo-Bar-Baz');
|
||||
|
||||
getSlug('Foo > Bar ♥ Baz', {
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('Foo-greater-than-Bar-love-Baz');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
16
node_modules/speakingurl/test/test-persian.js
generated
vendored
Normal file
16
node_modules/speakingurl/test/test-persian.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug translate persian letters/numbers', function () {
|
||||
'use strict';
|
||||
|
||||
it('should be ', function (done) {
|
||||
|
||||
getSlug('گ چ پ ژ ک ی ۰ ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹', {
|
||||
lang: 'fa'
|
||||
})
|
||||
.should.eql('g-ch-p-zh-k-y-0-1-2-3-4-5-6-7-8-9');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
128
node_modules/speakingurl/test/test-rfc3986.js
generated
vendored
Normal file
128
node_modules/speakingurl/test/test-rfc3986.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug rfc3986', function () {
|
||||
'use strict';
|
||||
|
||||
it('"uric" characters allowed', function (done) {
|
||||
|
||||
var chars = [';', '?', ':', '@', '&', '=', '+', ',', '/'];
|
||||
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
|
||||
getSlug("foo " + chars[i] + " bar baz", {
|
||||
uric: true
|
||||
})
|
||||
.should.eql("foo-" + chars[i] + "-bar-baz");
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('"uricNoSlash" characters allowed', function (done) {
|
||||
|
||||
var chars = [';', '?', ':', '@', '&', '=', '+', ','];
|
||||
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
getSlug("foo " + chars[i] + " bar baz", {
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql("foo-" + chars[i] + "-bar-baz");
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('"mark" characters allowed', function (done) {
|
||||
|
||||
var chars = ['.', '!', '~', '*', '\'', '(', ')'];
|
||||
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
getSlug("foo " + chars[i] + " bar baz", {
|
||||
mark: true
|
||||
})
|
||||
.should.eql("foo-" + chars[i] + "-bar-baz");
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('"uric" characters allowed, separator ";"', function (done) {
|
||||
|
||||
var chars = ['?', ':', '@', '&', '=', '+', ',', '/'];
|
||||
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
getSlug("foo " + chars[i] + " bar baz", {
|
||||
uric: true,
|
||||
separator: ';'
|
||||
})
|
||||
.should.eql("foo;" + chars[i] + ";bar;baz");
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('"uric" characters allowed, separator ";" included in input string', function (done) {
|
||||
|
||||
getSlug("foo ; bar baz", {
|
||||
uric: true,
|
||||
separator: ';'
|
||||
})
|
||||
.should.eql("foo;bar;baz");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('"uricNoSlash" characters allowed, separator ";"', function (done) {
|
||||
|
||||
var chars = ['?', ':', '@', '&', '=', '+', ','];
|
||||
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
getSlug("foo " + chars[i] + " bar baz", {
|
||||
uricNoSlash: true,
|
||||
separator: ';'
|
||||
})
|
||||
.should.eql("foo;" + chars[i] + ";bar;baz");
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('"uricNoSlash" characters allowed, separator ";" included in input string', function (done) {
|
||||
|
||||
getSlug("foo ; bar baz", {
|
||||
uric: true,
|
||||
separator: ';'
|
||||
})
|
||||
.should.eql("foo;bar;baz");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('"mark" characters allowed, separator "."', function (done) {
|
||||
|
||||
var chars = ['!', '~', '*', '\'', '(', ')'];
|
||||
|
||||
for (var i = 0; i < chars.length; i++) {
|
||||
getSlug("foo " + chars[i] + " bar baz", {
|
||||
mark: true,
|
||||
separator: '.'
|
||||
})
|
||||
.should.eql("foo." + chars[i] + ".bar.baz");
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('"mark" characters allowed, separator "." included in input string', function (done) {
|
||||
|
||||
getSlug("foo . bar baz", {
|
||||
uric: true,
|
||||
separator: '.'
|
||||
})
|
||||
.should.eql("foo.bar.baz");
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
181
node_modules/speakingurl/test/test-separator.js
generated
vendored
Normal file
181
node_modules/speakingurl/test/test-separator.js
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug separator', function () {
|
||||
'use strict';
|
||||
|
||||
it('should separate with non-whitespace', function (done) {
|
||||
|
||||
getSlug('Foo Bar Baz', {
|
||||
separator: '-'
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo Bar Baz', {
|
||||
separator: '*'
|
||||
})
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
getSlug('Foo Bar Baz', {
|
||||
separator: '_'
|
||||
})
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
getSlug('Foo Bar Baz', '-')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo Bar Baz', '*')
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
getSlug('Foo Bar Baz', '_')
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
|
||||
it('should separate with non-whitespace, with trailing spaces', function (done) {
|
||||
|
||||
getSlug(' Foo Bar Baz ', {
|
||||
separator: '-'
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug(' Foo Bar Baz ', {
|
||||
separator: '*'
|
||||
})
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
getSlug(' Foo Bar Baz ', {
|
||||
separator: '_'
|
||||
})
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
getSlug(' Foo Bar Baz ', '-')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug(' Foo Bar Baz ', '*')
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
getSlug(' Foo Bar Baz ', '_')
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
|
||||
it('should separate with trailing separator "-"', function (done) {
|
||||
|
||||
getSlug('-Foo Bar Baz-', {
|
||||
separator: '-'
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('--Foo Bar Baz---', {
|
||||
separator: '-'
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('---Foo Bar Baz---', {
|
||||
separator: '-'
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('-Foo Bar Baz-', '-')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('--Foo Bar Baz---', '-')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('---Foo Bar Baz---', '-')
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should separate with trailing separator "*"', function (done) {
|
||||
|
||||
getSlug('*Foo Bar Baz*', {
|
||||
separator: '*'
|
||||
})
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
getSlug('**Foo Bar Baz**', {
|
||||
separator: '*'
|
||||
})
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
getSlug('***Foo Bar Baz***', {
|
||||
separator: '*'
|
||||
})
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
getSlug('*Foo Bar Baz*', '*')
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
getSlug('**Foo Bar Baz**', '*')
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
getSlug('***Foo Bar Baz***', '*')
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
|
||||
it('should separate with trailing separator "_"', function (done) {
|
||||
|
||||
getSlug('_Foo Bar Baz_', {
|
||||
separator: '_'
|
||||
})
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
getSlug('__Foo Bar Baz__', {
|
||||
separator: '_'
|
||||
})
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
getSlug('___Foo Bar Baz___', {
|
||||
separator: '_'
|
||||
})
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
getSlug('_Foo Bar Baz_', '_')
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
getSlug('__Foo Bar Baz__', '_')
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
getSlug('___Foo Bar Baz___', '_')
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should remove trailing separator "*"', function (done) {
|
||||
|
||||
getSlug(' C\'est un beau titre qui ne laisse rien à désirer !', {
|
||||
separator: '*'
|
||||
})
|
||||
.should.eql(
|
||||
'c*est*un*beau*titre*qui*ne*laisse*rien*a*desirer');
|
||||
|
||||
getSlug(' C\'est un beau titre qui ne laisse rien à désirer !',
|
||||
'*')
|
||||
.should.eql(
|
||||
'c*est*un*beau*titre*qui*ne*laisse*rien*a*desirer');
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
|
||||
it('should return empty string because of non string input', function (done) {
|
||||
|
||||
getSlug(true)
|
||||
.should.eql('');
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
});
|
197
node_modules/speakingurl/test/test-speakingurl.js
generated
vendored
Normal file
197
node_modules/speakingurl/test/test-speakingurl.js
generated
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug config combinations', function () {
|
||||
'use strict';
|
||||
|
||||
it('should separate with configured character, with non-Base64 separator', function (done) {
|
||||
|
||||
getSlug('Foo, Bar Baz', {
|
||||
separator: '*',
|
||||
maintainCase: false
|
||||
})
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
getSlug('Foo- Bar Baz', {
|
||||
separator: '*',
|
||||
maintainCase: false
|
||||
})
|
||||
.should.eql('foo-*bar*baz');
|
||||
|
||||
getSlug('Foo] Bar Baz', {
|
||||
separator: '*',
|
||||
maintainCase: false
|
||||
})
|
||||
.should.eql('foo*bar*baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should separate with configured character, with only Base64 characters allowed', function (done) {
|
||||
|
||||
getSlug('Foo, Bar Baz', {
|
||||
separator: '_',
|
||||
onlyBase64: true
|
||||
})
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
getSlug('Foo- Bar Baz', {
|
||||
separator: '_',
|
||||
onlyBase64: true
|
||||
})
|
||||
.should.eql('foo-_bar_baz');
|
||||
|
||||
getSlug('Foo] Bar Baz', {
|
||||
separator: '_',
|
||||
onlyBase64: true
|
||||
})
|
||||
.should.eql('foo_bar_baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should separate with configured character, with smart trim', function (done) {
|
||||
|
||||
getSlug('Foobarbaz, Bar Baz', {
|
||||
separator: '_',
|
||||
truncate: 12
|
||||
})
|
||||
.should.eql('foobarbaz');
|
||||
|
||||
getSlug('Foobarbaz, Bar Baz', {
|
||||
separator: '_',
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('foobarbaz_bar');
|
||||
|
||||
getSlug(' Foobarbaz, Bar Baz', {
|
||||
separator: '_',
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('foobarbaz_bar');
|
||||
|
||||
getSlug(' Foobarbaz, Bar Baz', {
|
||||
separator: '_',
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('foobarbaz_bar');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should maintain case characters, with non-Base64 separator', function (done) {
|
||||
|
||||
getSlug('Foo, Bar Baz', {
|
||||
maintainCase: true,
|
||||
separator: '*'
|
||||
})
|
||||
.should.eql('Foo*Bar*Baz');
|
||||
|
||||
getSlug('Foo- Bar Baz', {
|
||||
maintainCase: true,
|
||||
separator: '*'
|
||||
})
|
||||
.should.eql('Foo-*Bar*Baz');
|
||||
|
||||
getSlug('Foo] Bar Baz', {
|
||||
maintainCase: true,
|
||||
separator: '*'
|
||||
})
|
||||
.should.eql('Foo*Bar*Baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should maintain case characters, with only Base64 characters allowed', function (done) {
|
||||
|
||||
getSlug('Foo, Bar Baz', {
|
||||
maintainCase: true,
|
||||
uric: false,
|
||||
uricNoSlash: false,
|
||||
mark: false
|
||||
})
|
||||
.should.eql('Foo-Bar-Baz');
|
||||
|
||||
getSlug('Foo- Bar Baz', {
|
||||
maintainCase: true,
|
||||
uric: false,
|
||||
uricNoSlash: false,
|
||||
mark: false
|
||||
})
|
||||
.should.eql('Foo-Bar-Baz');
|
||||
|
||||
getSlug('Foo] Bar Baz', {
|
||||
maintainCase: true,
|
||||
uric: false,
|
||||
uricNoSlash: false,
|
||||
mark: false
|
||||
})
|
||||
.should.eql('Foo-Bar-Baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should maintain case characters, with smart trim', function (done) {
|
||||
|
||||
getSlug('Foobarbaz, Bar Baz', {
|
||||
maintainCase: true,
|
||||
truncate: 12
|
||||
})
|
||||
.should.eql('Foobarbaz');
|
||||
|
||||
getSlug('Foobarbaz, Bar Baz', {
|
||||
maintainCase: true,
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('Foobarbaz-Bar');
|
||||
|
||||
getSlug(' Foobarbaz, Bar Baz', {
|
||||
maintainCase: true,
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('Foobarbaz-Bar');
|
||||
|
||||
getSlug(' Foobarbaz, Bar Baz', {
|
||||
maintainCase: true,
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('Foobarbaz-Bar');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should prefer Base64 characters only', function (done) {
|
||||
|
||||
getSlug('Foo, Bar Baz', {
|
||||
uric: false,
|
||||
uricNoSlash: false,
|
||||
mark: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo- Bar Baz', {
|
||||
uric: false,
|
||||
uricNoSlash: false,
|
||||
mark: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo] Bar Baz', {
|
||||
uric: false,
|
||||
uricNoSlash: false,
|
||||
mark: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
getSlug('Foo* Bar Baz', {
|
||||
uric: false,
|
||||
uricNoSlash: false,
|
||||
mark: false
|
||||
})
|
||||
.should.eql('foo-bar-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
506
node_modules/speakingurl/test/test-symbols.js
generated
vendored
Normal file
506
node_modules/speakingurl/test/test-symbols.js
generated
vendored
Normal file
@@ -0,0 +1,506 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug symbols', function () {
|
||||
'use strict';
|
||||
|
||||
it('should convert symbols', function (done) {
|
||||
|
||||
getSlug('Foo & Bar | Baz')
|
||||
.should.eql('foo-and-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'en'
|
||||
})
|
||||
.should.eql('foo-and-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'de'
|
||||
})
|
||||
.should.eql('foo-und-bar-oder-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'fr'
|
||||
})
|
||||
.should.eql('foo-et-bar-ou-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'es'
|
||||
})
|
||||
.should.eql('foo-y-bar-u-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'ru'
|
||||
})
|
||||
.should.eql('foo-i-bar-ili-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'cs'
|
||||
})
|
||||
.should.eql('foo-a-bar-nebo-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'sk'
|
||||
})
|
||||
.should.eql('foo-a-bar-alebo-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not convert symbols with uric flag true', function (done) {
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'en',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'de',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-oder-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'fr',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-ou-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'es',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-u-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'ru',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-ili-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'cs',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-nebo-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'sk',
|
||||
uric: true
|
||||
})
|
||||
.should.eql('foo-&-bar-alebo-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not convert symbols with uricNoSlash flag true', function (done) {
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'en',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-or-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'de',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-oder-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'fr',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-ou-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'es',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-u-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'ru',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-ili-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'cs',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-nebo-baz');
|
||||
|
||||
getSlug('Foo & Bar | Baz', {
|
||||
lang: 'sk',
|
||||
uricNoSlash: true
|
||||
})
|
||||
.should.eql('foo-&-bar-alebo-baz');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not convert symbols with mark flag true', function (done) {
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
mark: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'en',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . & Baz', {
|
||||
lang: 'en',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-and-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'de',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'fr',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'es',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'ru',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'cs',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
getSlug('Foo (Bar) . Baz', {
|
||||
lang: 'sk',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(bar)-.-baz');
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
|
||||
it('should convert symbols with flags true', function (done) {
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'en',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(love)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=& Bar', {
|
||||
lang: 'en',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(love)-;-baz=&-bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=& Bar', {
|
||||
lang: 'en',
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(love)-baz-and-bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'de',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(liebe)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'fr',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(amour)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'es',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(amor)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'ru',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(lubov)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'cs',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(laska)-;-baz=bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'sk',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true
|
||||
})
|
||||
.should.eql('foo-(laska)-;-baz=bar');
|
||||
|
||||
getSlug(' Sch(* )ner (♥)Ti♥tel ♥läßt grüßen!? Bel♥♥ été !', {
|
||||
lang: 'en',
|
||||
uric: true,
|
||||
uricNoSlash: true,
|
||||
mark: true,
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql(
|
||||
'Sch(*-)ner-(love)Ti-love-tel-love-laesst-gruessen!?-Bel-love-love-ete-!'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not convert symbols with flags true', function (done) {
|
||||
|
||||
getSlug('Foo (♥) ; Baz=Bar', {
|
||||
lang: 'en',
|
||||
mark: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-(-)-baz-bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=& Bar', {
|
||||
lang: 'en',
|
||||
mark: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-(-)-baz-bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=& Bar', {
|
||||
lang: 'en',
|
||||
mark: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-(-)-baz-bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz= & Bar', {
|
||||
lang: 'de',
|
||||
mark: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-(-)-baz-bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=& Bar', {
|
||||
lang: 'fr',
|
||||
mark: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-(-)-baz-bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=& Bar', {
|
||||
lang: 'es',
|
||||
mark: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-(-)-baz-bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=& Bar', {
|
||||
lang: 'ru',
|
||||
mark: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-(-)-baz-bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=& Bar', {
|
||||
lang: 'cs',
|
||||
mark: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-(-)-baz-bar');
|
||||
|
||||
getSlug('Foo (♥) ; Baz=& Bar', {
|
||||
lang: 'sk',
|
||||
mark: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('foo-(-)-baz-bar');
|
||||
|
||||
getSlug(' Sch(* )ner (♥)Ti♥tel ♥läßt grüßen!? Bel♥♥ été !', {
|
||||
lang: 'en',
|
||||
mark: true,
|
||||
maintainCase: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql(
|
||||
'Sch(*-)ner-(-)Ti-tel-laesst-gruessen!-Bel-ete-!'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should replace symbols (de)', function (done) {
|
||||
|
||||
getSlug('Äpfel & Birnen', {
|
||||
lang: 'de'
|
||||
})
|
||||
.should.eql('aepfel-und-birnen');
|
||||
|
||||
getSlug('ÄÖÜäöüß', {
|
||||
lang: 'de',
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('AeOeUeaeoeuess');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not replace symbols (de)', function (done) {
|
||||
|
||||
getSlug('Äpfel & Birnen', {
|
||||
lang: 'de',
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('aepfel-birnen');
|
||||
|
||||
getSlug('ÄÖÜäöüß & Äpfel', {
|
||||
lang: 'de',
|
||||
maintainCase: true,
|
||||
symbols: false
|
||||
})
|
||||
.should.eql('AeOeUeaeoeuess-Aepfel');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should replace chars by cs language standards', function (done) {
|
||||
|
||||
getSlug(
|
||||
'AaÁáBbCcČčDdĎďEeÉéĚěFfGgHhChchIiÍíJjKkLlMmNnŇňOoÓóPpQqRrŘřSsŠšTtŤťUuÚúŮůVvWwXxYyÝýZzŽž', {
|
||||
lang: 'cs'
|
||||
})
|
||||
.should.eql(
|
||||
'aaaabbccccddddeeeeeeffgghhchchiiiijjkkllmmnnnnooooppqqrrrrssssttttuuuuuuvvwwxxyyyyzzzz'
|
||||
);
|
||||
|
||||
getSlug(
|
||||
'AaÁáBbCcČčDdĎďEeÉéĚěFfGgHhChchIiÍíJjKkLlMmNnŇňOoÓóPpQqRrŘřSsŠšTtŤťUuÚúŮůVvWwXxYyÝýZzŽž', {
|
||||
lang: 'cs',
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql(
|
||||
'AaAaBbCcCcDdDdEeEeEeFfGgHhChchIiIiJjKkLlMmNnNnOoOoPpQqRrRrSsSsTtTtUuUuUuVvWwXxYyYyZzZz'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should replace chars by sk language standards', function (done) {
|
||||
|
||||
getSlug(
|
||||
'AaÁaÄäBbCcČčDdĎďDzdzDždžEeÉéFfGgHhChchIiÍíJjKkLlĹ弾MmNnŇňOoÓóÔôPpQqRrŔŕSsŠšTtŤťUuÚúVvWwXxYyÝýZzŽž', {
|
||||
lang: 'sk'
|
||||
})
|
||||
.should.eql(
|
||||
'aaaaaabbccccdddddzdzdzdzeeeeffgghhchchiiiijjkkllllllmmnnnnooooooppqqrrrrssssttttuuuuvvwwxxyyyyzzzz'
|
||||
);
|
||||
|
||||
getSlug(
|
||||
'AaÁaÄäBbCcČčDdĎďDzdzDždžEeÉéFfGgHhChchIiÍíJjKkLlĹ弾MmNnŇňOoÓóÔôPpQqRrŔŕSsŠšTtŤťUuÚúVvWwXxYyÝýZzŽž', {
|
||||
lang: 'sk',
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql(
|
||||
'AaAaAaBbCcCcDdDdDzdzDzdzEeEeFfGgHhChchIiIiJjKkLlLlLlMmNnNnOoOoOoPpQqRrRrSsSsTtTtUuUuVvWwXxYyYyZzZz'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should ignore not available language param', function (done) {
|
||||
|
||||
getSlug('Äpfel & Birnen', {
|
||||
lang: 'xx'
|
||||
})
|
||||
.should.eql('aepfel-and-birnen');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should convert currency symbols to lowercase', function (done) {
|
||||
|
||||
getSlug('NEXUS4 only €199!', {
|
||||
maintainCase: false
|
||||
})
|
||||
.should.eql('nexus4-only-eur199');
|
||||
|
||||
getSlug('NEXUS4 only €299.93', {
|
||||
maintainCase: false
|
||||
})
|
||||
.should.eql('nexus4-only-eur299-93');
|
||||
|
||||
getSlug('NEXUS4 only 円399.73', {
|
||||
maintainCase: false
|
||||
})
|
||||
.should.eql('nexus4-only-yen399-73');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should convert currency symbols to uppercase', function (done) {
|
||||
|
||||
getSlug('NEXUS4 only €199!', {
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('NEXUS4-only-EUR199');
|
||||
|
||||
getSlug('NEXUS4 only €299.93', {
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('NEXUS4-only-EUR299-93');
|
||||
|
||||
getSlug('NEXUS4 only 円399.73', {
|
||||
maintainCase: true
|
||||
})
|
||||
.should.eql('NEXUS4-only-YEN399-73');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
69
node_modules/speakingurl/test/test-titlecase.js
generated
vendored
Normal file
69
node_modules/speakingurl/test/test-titlecase.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug titleCase', function () {
|
||||
'use strict';
|
||||
|
||||
it('should title-case the characters', function (done) {
|
||||
|
||||
getSlug('This is big foo', {
|
||||
titleCase: true
|
||||
})
|
||||
.should.eql('This-Is-Big-Foo');
|
||||
|
||||
getSlug('This is Big foo', {
|
||||
titleCase: true
|
||||
})
|
||||
.should.eql('This-Is-Big-Foo');
|
||||
|
||||
getSlug('Don\'t drink and drive', {
|
||||
titleCase: true
|
||||
})
|
||||
.should.eql('Don-t-Drink-And-Drive');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should title-case the characters with custom array', function (done) {
|
||||
|
||||
getSlug('This is yet foo and bar', {
|
||||
titleCase: ['and', 'yet']
|
||||
})
|
||||
.should.eql('This-Is-yet-Foo-and-Bar');
|
||||
|
||||
getSlug('This is a foo and an angry bird', {
|
||||
titleCase: ['a', 'an', 'and']
|
||||
})
|
||||
.should.eql('This-Is-a-Foo-and-an-Angry-Bird');
|
||||
|
||||
getSlug('This is a foo and an angry bird show', {
|
||||
titleCase: ['a']
|
||||
})
|
||||
.should.eql('This-Is-a-Foo-And-An-Angry-Bird-Show');
|
||||
|
||||
getSlug('Don\'t drink and drive', {
|
||||
titleCase: ['and']
|
||||
})
|
||||
.should.eql('Don-t-Drink-and-Drive');
|
||||
|
||||
getSlug('Don\'t drink and drive', {
|
||||
titleCase: {}
|
||||
})
|
||||
.should.eql('Don-t-Drink-And-Drive');
|
||||
|
||||
getSlug('Don\'t drink and drive', {
|
||||
titleCase: {
|
||||
'drink': 'drive'
|
||||
}
|
||||
})
|
||||
.should.eql('Don-t-Drink-And-Drive');
|
||||
|
||||
getSlug('Don\'t drink and drive', {
|
||||
titleCase: 42
|
||||
})
|
||||
.should.eql('Don-t-Drink-And-Drive');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
68
node_modules/speakingurl/test/test-truncate.js
generated
vendored
Normal file
68
node_modules/speakingurl/test/test-truncate.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug smart truncate', function () {
|
||||
'use strict';
|
||||
|
||||
it('should maintain case characters, with smart truncate', function (done) {
|
||||
|
||||
getSlug('Foobarbaz, Bar Baz', {
|
||||
truncate: 12
|
||||
})
|
||||
.should.eql('foobarbaz');
|
||||
|
||||
getSlug('Foobarbaz, Bar Baz', {
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('foobarbaz-bar');
|
||||
|
||||
getSlug(' Foobarbaz, Bar Baz', {
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('foobarbaz-bar');
|
||||
|
||||
getSlug(' Foobarbaz, Bar Baz', {
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('foobarbaz-bar');
|
||||
|
||||
getSlug('Foo Foo bar Zoo Bar Baz', {
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('foo-foo-bar-zoo');
|
||||
|
||||
getSlug('Foo Foo bar ZooBar Baz', {
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('foo-foo-bar');
|
||||
|
||||
getSlug('Foo Foo bar ZooBar Baz', {
|
||||
truncate: 15
|
||||
})
|
||||
.should.eql('foo-foo-bar');
|
||||
|
||||
getSlug('Foo Foo Bar Bar', {
|
||||
truncate: "foo"
|
||||
})
|
||||
.should.eql('foo-foo-bar-bar');
|
||||
|
||||
getSlug('Foo Foo Bar Bar', {
|
||||
truncate: false
|
||||
})
|
||||
.should.eql('foo-foo-bar-bar');
|
||||
|
||||
getSlug('Foo Foo Bar Bar', {
|
||||
truncate: true
|
||||
})
|
||||
.should.eql('foo-foo-bar-bar');
|
||||
|
||||
getSlug('a Foo', {
|
||||
truncate: true
|
||||
})
|
||||
.should.eql('a-foo');
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
});
|
23
node_modules/speakingurl/test/test-turkish.js
generated
vendored
Normal file
23
node_modules/speakingurl/test/test-turkish.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/* global describe,it */
|
||||
|
||||
var getSlug = require('../lib/speakingurl');
|
||||
|
||||
describe('getSlug translate turkish letters', function () {
|
||||
'use strict';
|
||||
|
||||
it('umlaut should be single letter transliteration', function (done) {
|
||||
|
||||
getSlug('ÜÄÖüäö', {
|
||||
lang: 'tr'
|
||||
})
|
||||
.should.eql('uaeouaeo');
|
||||
|
||||
getSlug('ÜÖÄ äüö', {
|
||||
lang: 'tr'
|
||||
})
|
||||
.should.eql('uoae-aeuo');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
90
node_modules/speakingurl/typings/speakingurl/speakingurl.d.ts
generated
vendored
Normal file
90
node_modules/speakingurl/typings/speakingurl/speakingurl.d.ts
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Interface for the SpeakingURL options
|
||||
* @see {@link https://github.com/pid/speakingurl#usage}
|
||||
*/
|
||||
interface speakingurlOptions {
|
||||
/**
|
||||
* Character that replaces the whitespaces
|
||||
* @default '-'
|
||||
*/
|
||||
separator?: string;
|
||||
/**
|
||||
* ISO 639-1 Codes for language specific transliteration
|
||||
* @default 'en'
|
||||
*/
|
||||
lang?: string | boolean;
|
||||
|
||||
/**
|
||||
* Converts symbols according to the 'lang' setting if true. Don't convert symbols if false
|
||||
* @default true
|
||||
*/
|
||||
symbols?: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Maintains case chars if true. Convert all chars to lower case if false
|
||||
* @default false
|
||||
*/
|
||||
maintainCase?: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* converts input string to title-case if true. Omit the words from the array if array is given.
|
||||
* @default false
|
||||
*/
|
||||
titleCase?: boolean | Array<string>;
|
||||
|
||||
|
||||
/**
|
||||
* Don't trim length if 0. Trim to max length while not breaking any words if greater or equal to 1.
|
||||
* @default 0
|
||||
*/
|
||||
truncate?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Allow additional characters if true.
|
||||
* Characters allowed: ";", "?", ":", "@", "&", "=", "+", "\$", ",", "/"
|
||||
* @default false
|
||||
*/
|
||||
uric?: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Allow additional characters if true.
|
||||
* Characters allowed: ";", "?", ":", "@", "&", "=", "+", "\$", ","
|
||||
* @default false
|
||||
*/
|
||||
uricNoSlash?: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Allow additional characters if true.
|
||||
* Characters allowed: "-", "_", ".", "!", "~", "*", "'", "(", ")"
|
||||
* @default false
|
||||
*/
|
||||
mark?: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* custom map for translation if object provided. Add array chars to allowed charMap if array provided.
|
||||
* @default {}
|
||||
*/
|
||||
custom?: Object | Array<string>
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines slug from given input.
|
||||
* @param {string} input string to convert
|
||||
* @param {object|string} options configuration object or separator string
|
||||
* @return {string} slug
|
||||
*/
|
||||
declare function getSlug(input: string, options?: speakingurlOptions | string): string;
|
||||
|
||||
/**
|
||||
* @function createSlug
|
||||
* @param {object|string} options configuration object or separator string
|
||||
*/
|
||||
declare function createSlug(options?: speakingurlOptions | string): ((input: string) => string);
|
Reference in New Issue
Block a user