diff --git a/site/README.md b/site/README.md index 223830b3fa3d..1ba94e8b5675 100644 --- a/site/README.md +++ b/site/README.md @@ -29,4 +29,4 @@ BASEURL=http://localhost:3000 Anchors are automatically generated using headings in the documentation and by default (for the english language) they are latinised to make sure the URL is always conforming to RFC3986. -If we need to translate the API documentation to a language using unicode chars, we can setup this app to export the correct anchors by setting up `SLUG_PRESERVE_UNICODE` to `true` and `SLUG_LANG` to the ISO 639-1 two-letter language code of your choice in `config.js`. +If we need to translate the API documentation to a language using unicode chars, we can setup this app to export the correct anchors by setting up `SLUG_PRESERVE_UNICODE` to `true` in `config.js`. diff --git a/site/config.js b/site/config.js index 25dfce0c2232..097bd173a863 100644 --- a/site/config.js +++ b/site/config.js @@ -1,3 +1,2 @@ export const SLUG_PRESERVE_UNICODE = false; export const SLUG_SEPARATOR = '_'; -export const SLUG_LANG = 'en'; diff --git a/site/package-lock.json b/site/package-lock.json index a96697a7f2be..67dc58599169 100644 --- a/site/package-lock.json +++ b/site/package-lock.json @@ -1370,6 +1370,16 @@ "resolved": "https://registry.npmjs.org/@polka/url/-/url-0.5.0.tgz", "integrity": "sha512-oZLYFEAzUKyi3SKnXvj32ZCEGH6RDnao7COuCVhDydMS9NrCSVXhM79VaKyP5+Zc33m0QXEd2DN3UkU7OsHcfw==" }, + "@sindresorhus/slugify": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@sindresorhus/slugify/-/slugify-0.9.1.tgz", + "integrity": "sha512-b6heYM9dzZD13t2GOiEQTDE0qX+I1GyOotMwKh9VQqzuNiVdPVT8dM43fe9HNb/3ul+Qwd5oKSEDrDIfhq3bnQ==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5", + "lodash.deburr": "^4.1.0" + } + }, "@sveltejs/svelte-repl": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/@sveltejs/svelte-repl/-/svelte-repl-0.0.10.tgz", @@ -1401,15 +1411,6 @@ "@types/node": "*" } }, - "accepts": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", - "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", - "requires": { - "mime-types": "~2.1.18", - "negotiator": "0.6.1" - } - }, "acorn": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", @@ -1704,16 +1705,6 @@ "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", "dev": true }, - "bulk-replace": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/bulk-replace/-/bulk-replace-0.0.1.tgz", - "integrity": "sha1-8JVoKolqvUs9ngjeQJzCIuIT+d0=" - }, - "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" - }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -2478,7 +2469,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -2502,13 +2494,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2525,19 +2519,22 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2668,7 +2665,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2682,6 +2680,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2698,6 +2697,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2706,13 +2706,15 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2733,6 +2735,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2821,7 +2824,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2835,6 +2839,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2930,7 +2935,8 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2972,6 +2978,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2993,6 +3000,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3041,13 +3049,15 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true + "dev": true, + "optional": true } } }, @@ -3212,14 +3222,6 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, - "hepburn": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/hepburn/-/hepburn-1.1.1.tgz", - "integrity": "sha512-Ok3ZmMJN3ek4WFAL4f5t8k+BmrDRlS5qGjI4um+3cHH0SrYVzJgUTYwIfGvU8s/eWqOEY+gsINwjJSoaBG3A9g==", - "requires": { - "bulk-replace": "0.0.1" - } - }, "home-or-tmp": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-3.0.0.tgz", @@ -3619,11 +3621,6 @@ "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true }, - "keypress": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz", - "integrity": "sha1-SjGI1CkbZrT2XtuZ+AaqmuKTWSo=" - }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", @@ -3639,16 +3636,6 @@ "invert-kv": "^2.0.0" } }, - "limax": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/limax/-/limax-1.7.0.tgz", - "integrity": "sha512-ibcGylOXT5vry2JKfKwLWx2tZudRYWm4SzG9AE/cc5zqwW+3nQy/uPLUvfAUChRdmqxVrK6SNepmO7ZY8RoKfA==", - "requires": { - "hepburn": "^1.1.0", - "pinyin": "^2.8.3", - "speakingurl": "^14.0.1" - } - }, "load-bmfont": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.0.tgz", @@ -3693,6 +3680,12 @@ "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, + "lodash.deburr": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/lodash.deburr/-/lodash.deburr-4.1.0.tgz", + "integrity": "sha1-3bG7s+8HRYwBd7oH3hRCLLAz/5s=", + "dev": true + }, "log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -3808,19 +3801,6 @@ "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", "dev": true }, - "mime-db": { - "version": "1.38.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", - "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" - }, - "mime-types": { - "version": "2.1.22", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", - "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", - "requires": { - "mime-db": "~1.38.0" - } - }, "mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -4001,11 +3981,6 @@ "to-regex": "^3.0.1" } }, - "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" - }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -4045,23 +4020,6 @@ "semver": "^5.3.0" } }, - "nodejieba": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/nodejieba/-/nodejieba-2.3.0.tgz", - "integrity": "sha512-ZzLsVuNDlrmcBQa/b8G/yegdXje2iFmktYmPksk6qLha1brKEANYqg4XPiBspF1D0y7Npho91KTmvKFcDr0UdA==", - "optional": true, - "requires": { - "nan": "~2.10.0" - }, - "dependencies": { - "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", - "optional": true - } - } - }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -4433,26 +4391,6 @@ "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "dev": true }, - "pinyin": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/pinyin/-/pinyin-2.8.3.tgz", - "integrity": "sha1-MBzLQ1jM/oAlI8S9ZAphK+5NfEs=", - "requires": { - "commander": "~1.1.1", - "nodejieba": "^2.2.1", - "object-assign": "^4.0.1" - }, - "dependencies": { - "commander": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-1.1.1.tgz", - "integrity": "sha1-UNFlGGiuYOzP8KLZ80WVN2vGsEE=", - "requires": { - "keypress": "0.1.x" - } - } - } - }, "pixelmatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-4.0.2.tgz", @@ -5206,11 +5144,6 @@ "integrity": "sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==", "dev": true }, - "speakingurl": { - "version": "14.0.1", - "resolved": "https://registry.npmjs.org/speakingurl/-/speakingurl-14.0.1.tgz", - "integrity": "sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==" - }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -5649,11 +5582,6 @@ "spdx-expression-parse": "^3.0.0" } }, - "vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" - }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", diff --git a/site/package.json b/site/package.json index 437cf0680d4b..e3a0a3b67f31 100644 --- a/site/package.json +++ b/site/package.json @@ -20,7 +20,6 @@ "do-not-zip": "^1.0.0", "express-session": "^1.15.6", "golden-fleece": "^1.0.9", - "limax": "^1.7.0", "marked": "^0.6.1", "node-fetch": "^2.3.0", "passport": "^0.4.0", @@ -38,6 +37,7 @@ "@babel/plugin-transform-runtime": "^7.2.0", "@babel/preset-env": "^7.3.1", "@babel/runtime": "^7.3.1", + "@sindresorhus/slugify": "^0.9.1", "@sveltejs/svelte-repl": "0.0.10", "chokidar": "^2.1.2", "degit": "^2.1.3", diff --git a/site/src/utils/slug.js b/site/src/utils/slug.js index 4ad7b96b2a76..79b82c12ceb1 100644 --- a/site/src/utils/slug.js +++ b/site/src/utils/slug.js @@ -1,14 +1,20 @@ -import limax from 'limax'; -import {SLUG_LANG, SLUG_SEPARATOR} from '../../config'; +import slugify from '@sindresorhus/slugify'; +import {SLUG_SEPARATOR} from '../../config'; -/* latinizer processor */ +/* url-safe processor */ -export const limaxProcessor = (string, lang = SLUG_LANG) => limax(string, { - custom: ['$'], - separator: SLUG_SEPARATOR, - maintainCase: true, - lang -}); +export const urlsafeSlugProcessor = string => + slugify(string, { + customReplacements: [ // runs before any other transformations + ['$', 'DOLLAR'], // `$destroy` & co + ['-', 'DASH'], // conflicts with `separator` + ], + separator: SLUG_SEPARATOR, + decamelize: false, + lowercase: false + }) + .replace(/DOLLAR/g, '$') + .replace(/DASH/g, '-'); /* unicode-preserver processor */ @@ -40,7 +46,7 @@ export const unicodeSafeProcessor = string => .chunks .reduce((accum, chunk) => { const processed = chunk.type === 'process' - ? limaxProcessor(chunk.string) + ? urlsafeSlugProcessor(chunk.string) : chunk.string; processed.length > 0 && accum.push(processed); @@ -52,7 +58,7 @@ export const unicodeSafeProcessor = string => /* session processor */ export const makeSessionSlugProcessor = (preserveUnicode = false) => { - const processor = preserveUnicode ? unicodeSafeProcessor : limaxProcessor; + const processor = preserveUnicode ? unicodeSafeProcessor : urlsafeSlugProcessor; const seen = new Set(); return string => { diff --git a/site/test/utils/slug.js b/site/test/utils/slug.js index c6d6c966857b..17262c5e8387 100644 --- a/site/test/utils/slug.js +++ b/site/test/utils/slug.js @@ -1,61 +1,61 @@ import {strict as assert} from 'assert'; -import {limaxProcessor, unicodeSafeProcessor} from '../../src/utils/slug'; -import {SLUG_SEPARATOR as _, SLUG_LANG} from '../../config'; +import {urlsafeSlugProcessor, unicodeSafeProcessor} from '../../src/utils/slug'; +import {SLUG_SEPARATOR as _} from '../../config'; describe('slug', () => { - describe('limaxProcessor (latinize unicode)', () => { + describe('urlsafeSlugProcessor', () => { describe('ascii', () => { it('space separated words', () => { assert.equal( - limaxProcessor('Text expressions'), - `text${_}expressions` + urlsafeSlugProcessor('Text expressions'), + `Text${_}expressions` ); }); it('numbered text', () => { assert.equal( - limaxProcessor('1. export creates'), + urlsafeSlugProcessor('1. export creates'), `1${_}export${_}creates` ); }); it('punctuated text', () => { assert.equal( - limaxProcessor('svelte.VERSION'), - `svelte${_}version` + urlsafeSlugProcessor('svelte.VERSION'), + `svelte${_}VERSION` ); }); it('text starting with the dollar sign', () => { assert.equal( - limaxProcessor('$destroy method'), + urlsafeSlugProcessor('$destroy method'), `$destroy${_}method` ); }); it('numbered text containing the dollar sign', () => { assert.equal( - limaxProcessor('1. export $destroy'), + urlsafeSlugProcessor('1. export $destroy'), `1${_}export${_}$destroy` ); }); it('text containing the equal char', () => { assert.equal( - limaxProcessor('script context=module'), + urlsafeSlugProcessor('script context=module'), `script${_}context${_}module` ); }); it('text containing the colon char', () => { assert.equal( - limaxProcessor('svelte:body'), + urlsafeSlugProcessor('svelte:body'), `svelte${_}body` ); }); it('text containing the slash char', () => { assert.equal( - limaxProcessor('svelte/motion'), + urlsafeSlugProcessor('svelte/motion'), `svelte${_}motion` ); }); it('text containing the comma char', () => { assert.equal( - limaxProcessor('svelte, motion'), + urlsafeSlugProcessor('svelte, motion'), `svelte${_}motion` ); }); @@ -63,156 +63,150 @@ describe('slug', () => { describe('unicode', () => { it('should translate symbols to English', () => { assert.equal( - limaxProcessor('Ich ♥ Deutsch'), - `ich${_}love${_}deutsch` + urlsafeSlugProcessor('Ich ♥ Deutsch'), + `Ich${_}love${_}Deutsch` ); }); it('should remove emoji', () => { assert.equal( - limaxProcessor('Ich 😍 Deutsch'), - `ich${_}deutsch` - ); - }); - it('should translate symbols to the given language (German)', () => { - assert.equal( - limaxProcessor('Ich ♥ Deutsch', 'de'), - `ich${_}liebe${_}deutsch` + urlsafeSlugProcessor('Ich 😍 Deutsch'), + `Ich${_}Deutsch` ); }); }); describe('cyricllic', () => { it('space separated words', () => { assert.equal( - limaxProcessor('Всплытие и перехват событий'), - `vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие и перехват событий'), + `Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('numbered text', () => { assert.equal( - limaxProcessor('1 Всплытие и перехват событий'), - `1${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('1 Всплытие и перехват событий'), + `1${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('punctuated text', () => { assert.equal( - limaxProcessor('.Всплытие.и.перехват событий'), - `vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('.Всплытие.и.перехват событий'), + `Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text starting with the dollar sign', () => { assert.equal( - limaxProcessor('$Всплытие $ перехват событий'), - `$vsplytie${_}$${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('$Всплытие $ перехват событий'), + `$Vsplytie${_}$${_}perehvat${_}sobytij` ); }); it('text containing the dollar sign', () => { assert.equal( - limaxProcessor('Всплытие$перехват'), - `vsplytie$perekhvat` + urlsafeSlugProcessor('Всплытие$перехват'), + `Vsplytie$perehvat` ); }); it('text containing the equal char', () => { assert.equal( - limaxProcessor('Всплытие = перехват=событий'), - `vsplytie${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие = перехват=событий'), + `Vsplytie${_}perehvat${_}sobytij` ); }); it('text containing the colon char', () => { assert.equal( - limaxProcessor('Всплытие : перехват:событий'), - `vsplytie${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие : перехват:событий'), + `Vsplytie${_}perehvat${_}sobytij` ); }); it('text containing the slash char', () => { assert.equal( - limaxProcessor('Всплытие / перехват/событий'), - `vsplytie${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие / перехват/событий'), + `Vsplytie${_}perehvat${_}sobytij` ); }); it('text containing the comma char', () => { assert.equal( - limaxProcessor('Всплытие, перехват'), - `vsplytie${_}perekhvat` + urlsafeSlugProcessor('Всплытие, перехват'), + `Vsplytie${_}perehvat` ); }); }); describe('ascii + cyricllic', () => { it('space separated words', () => { assert.equal( - limaxProcessor('Всплытие и export перехват событий'), - `vsplytie${_}i${_}export${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие и export перехват событий'), + `Vsplytie${_}i${_}export${_}perehvat${_}sobytij` ); }); it('ascii word concatenated to a cyricllic word', () => { assert.equal( - limaxProcessor('exportВсплытие'), - 'exportvsplytie' + urlsafeSlugProcessor('exportВсплытие'), + 'exportVsplytie' ); }); it('cyricllic word concatenated to an ascii word', () => { assert.equal( - limaxProcessor('Всплытиеexport'), - `vsplytieexport` + urlsafeSlugProcessor('Всплытиеexport'), + `Vsplytieexport` ); }); it('numbered text', () => { assert.equal( - limaxProcessor('1 export Всплытие и перехват событий'), - `1${_}export${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('1 export Всплытие и перехват событий'), + `1${_}export${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('punctuated text', () => { assert.equal( - limaxProcessor('.Всплытие.export.и.перехват событий'), - `vsplytie${_}export${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('.Всплытие.export.и.перехват событий'), + `Vsplytie${_}export${_}i${_}perehvat${_}sobytij` ); }); it('text starting with the dollar sign, followed by ascii char', () => { assert.equal( - limaxProcessor('$exportВсплытие перехват событий'), - `$exportvsplytie${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('$exportВсплытие перехват событий'), + `$exportVsplytie${_}perehvat${_}sobytij` ); }); it('text starting with the dollar sign, followed by unicode char', () => { assert.equal( - limaxProcessor('$Всплытие export перехват событий'), - `$vsplytie${_}export${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('$Всплытие export перехват событий'), + `$Vsplytie${_}export${_}perehvat${_}sobytij` ); }); it('text containing the dollar sign, followed by ascii char', () => { assert.equal( - limaxProcessor('export $destroy a component prop Всплытие и перехват событий'), - `export${_}$destroy${_}a${_}component${_}prop${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('export $destroy a component prop Всплытие и перехват событий'), + `export${_}$destroy${_}a${_}component${_}prop${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text containing the dollar sign, followed by unicode char', () => { assert.equal( - limaxProcessor('Всплытие export $Всплытие a component prop Всплытие и перехват событий'), - `vsplytie${_}export${_}$vsplytie${_}a${_}component${_}prop${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('Всплытие export $Всплытие a component prop Всплытие и перехват событий'), + `Vsplytie${_}export${_}$Vsplytie${_}a${_}component${_}prop${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text containing the equal char', () => { assert.equal( - limaxProcessor('script context=module Всплытие=и перехват событий'), - `script${_}context${_}module${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('script context=module Всплытие=и перехват событий'), + `script${_}context${_}module${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text containing the colon char', () => { assert.equal( - limaxProcessor('svelte:body Всплытие и:перехват событий'), - `svelte${_}body${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('svelte:body Всплытие и:перехват событий'), + `svelte${_}body${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text containing the slash char', () => { assert.equal( - limaxProcessor('svelte/motion Всплытие и / перехват/событий'), - `svelte${_}motion${_}vsplytie${_}i${_}perekhvat${_}sobytii` + urlsafeSlugProcessor('svelte/motion Всплытие и / перехват/событий'), + `svelte${_}motion${_}Vsplytie${_}i${_}perehvat${_}sobytij` ); }); it('text containing the comma char', () => { assert.equal( - limaxProcessor('Всплытие, export'), - `vsplytie${_}export` + urlsafeSlugProcessor('Всплытие, export'), + `Vsplytie${_}export` ); }); }); @@ -223,7 +217,7 @@ describe('slug', () => { it('space separated words', () => { assert.equal( unicodeSafeProcessor('Text expressions'), - `text${_}expressions` + `Text${_}expressions` ); }); it('numbered text', () => { @@ -235,7 +229,7 @@ describe('slug', () => { it('punctuated text', () => { assert.equal( unicodeSafeProcessor('svelte.VERSION'), - `svelte${_}version` + `svelte${_}VERSION` ); }); it('text starting with the dollar sign', () => { @@ -279,13 +273,13 @@ describe('slug', () => { it('should preserve symbols', () => { assert.equal( unicodeSafeProcessor('Ich ♥ Deutsch'), - `ich${_}love${_}deutsch` + `Ich${_}love${_}Deutsch` ); }); it('should remove emoji', () => { assert.equal( unicodeSafeProcessor('Ich 😍 Deutsch'), - `ich${_}deutsch` + `Ich${_}Deutsch` ); }); });