Site: use pure javascript slugification library

This library doesn't support languages but it has only 2 dependencies being free from native dependencies

Closes #2508
pull/2593/head
Luca Bonavita 6 years ago committed by Conduitry
parent e0bebb56a9
commit 788519b1c4

@ -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. 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`.

@ -1,3 +1,2 @@
export const SLUG_PRESERVE_UNICODE = false; export const SLUG_PRESERVE_UNICODE = false;
export const SLUG_SEPARATOR = '_'; export const SLUG_SEPARATOR = '_';
export const SLUG_LANG = 'en';

@ -1370,6 +1370,16 @@
"resolved": "https://registry.npmjs.org/@polka/url/-/url-0.5.0.tgz", "resolved": "https://registry.npmjs.org/@polka/url/-/url-0.5.0.tgz",
"integrity": "sha512-oZLYFEAzUKyi3SKnXvj32ZCEGH6RDnao7COuCVhDydMS9NrCSVXhM79VaKyP5+Zc33m0QXEd2DN3UkU7OsHcfw==" "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": { "@sveltejs/svelte-repl": {
"version": "0.0.10", "version": "0.0.10",
"resolved": "https://registry.npmjs.org/@sveltejs/svelte-repl/-/svelte-repl-0.0.10.tgz", "resolved": "https://registry.npmjs.org/@sveltejs/svelte-repl/-/svelte-repl-0.0.10.tgz",
@ -1401,15 +1411,6 @@
"@types/node": "*" "@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": { "acorn": {
"version": "6.1.1", "version": "6.1.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz",
@ -1704,16 +1705,6 @@
"integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==",
"dev": true "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": { "cache-base": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz",
@ -2478,7 +2469,8 @@
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
"dev": true "dev": true,
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@ -2502,13 +2494,15 @@
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true "dev": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -2525,19 +2519,22 @@
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
"dev": true "dev": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true "dev": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
"dev": true "dev": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -2668,7 +2665,8 @@
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true "dev": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "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", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -2698,6 +2697,7 @@
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -2706,13 +2706,15 @@
"version": "0.0.8", "version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true "dev": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.3.5", "version": "2.3.5",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz",
"integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -2733,6 +2735,7 @@
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -2821,7 +2824,8 @@
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
"dev": true "dev": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -2835,6 +2839,7 @@
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -2930,7 +2935,8 @@
"version": "5.1.2", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"dev": true "dev": true,
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@ -2972,6 +2978,7 @@
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^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", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -3041,13 +3049,15 @@
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true "dev": true,
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz",
"integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", "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==", "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"dev": true "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": { "home-or-tmp": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-3.0.0.tgz", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-3.0.0.tgz",
@ -3619,11 +3621,6 @@
"integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
"dev": true "dev": true
}, },
"keypress": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz",
"integrity": "sha1-SjGI1CkbZrT2XtuZ+AaqmuKTWSo="
},
"kind-of": { "kind-of": {
"version": "6.0.2", "version": "6.0.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
@ -3639,16 +3636,6 @@
"invert-kv": "^2.0.0" "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": { "load-bmfont": {
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.0.tgz", "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.0.tgz",
@ -3693,6 +3680,12 @@
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
"dev": true "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": { "log-symbols": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz",
@ -3808,19 +3801,6 @@
"integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==",
"dev": true "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": { "mimic-fn": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
@ -4001,11 +3981,6 @@
"to-regex": "^3.0.1" "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": { "nice-try": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
@ -4045,23 +4020,6 @@
"semver": "^5.3.0" "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": { "normalize-package-data": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
@ -4433,26 +4391,6 @@
"integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=",
"dev": true "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": { "pixelmatch": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-4.0.2.tgz", "resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-4.0.2.tgz",
@ -5206,11 +5144,6 @@
"integrity": "sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==", "integrity": "sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==",
"dev": true "dev": true
}, },
"speakingurl": {
"version": "14.0.1",
"resolved": "https://registry.npmjs.org/speakingurl/-/speakingurl-14.0.1.tgz",
"integrity": "sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ=="
},
"split-string": { "split-string": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
@ -5649,11 +5582,6 @@
"spdx-expression-parse": "^3.0.0" "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": { "which": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",

@ -20,7 +20,6 @@
"do-not-zip": "^1.0.0", "do-not-zip": "^1.0.0",
"express-session": "^1.15.6", "express-session": "^1.15.6",
"golden-fleece": "^1.0.9", "golden-fleece": "^1.0.9",
"limax": "^1.7.0",
"marked": "^0.6.1", "marked": "^0.6.1",
"node-fetch": "^2.3.0", "node-fetch": "^2.3.0",
"passport": "^0.4.0", "passport": "^0.4.0",
@ -38,6 +37,7 @@
"@babel/plugin-transform-runtime": "^7.2.0", "@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.3.1", "@babel/preset-env": "^7.3.1",
"@babel/runtime": "^7.3.1", "@babel/runtime": "^7.3.1",
"@sindresorhus/slugify": "^0.9.1",
"@sveltejs/svelte-repl": "0.0.10", "@sveltejs/svelte-repl": "0.0.10",
"chokidar": "^2.1.2", "chokidar": "^2.1.2",
"degit": "^2.1.3", "degit": "^2.1.3",

@ -1,14 +1,20 @@
import limax from 'limax'; import slugify from '@sindresorhus/slugify';
import {SLUG_LANG, SLUG_SEPARATOR} from '../../config'; import {SLUG_SEPARATOR} from '../../config';
/* latinizer processor */ /* url-safe processor */
export const limaxProcessor = (string, lang = SLUG_LANG) => limax(string, { export const urlsafeSlugProcessor = string =>
custom: ['$'], slugify(string, {
separator: SLUG_SEPARATOR, customReplacements: [ // runs before any other transformations
maintainCase: true, ['$', 'DOLLAR'], // `$destroy` & co
lang ['-', 'DASH'], // conflicts with `separator`
}); ],
separator: SLUG_SEPARATOR,
decamelize: false,
lowercase: false
})
.replace(/DOLLAR/g, '$')
.replace(/DASH/g, '-');
/* unicode-preserver processor */ /* unicode-preserver processor */
@ -40,7 +46,7 @@ export const unicodeSafeProcessor = string =>
.chunks .chunks
.reduce((accum, chunk) => { .reduce((accum, chunk) => {
const processed = chunk.type === 'process' const processed = chunk.type === 'process'
? limaxProcessor(chunk.string) ? urlsafeSlugProcessor(chunk.string)
: chunk.string; : chunk.string;
processed.length > 0 && accum.push(processed); processed.length > 0 && accum.push(processed);
@ -52,7 +58,7 @@ export const unicodeSafeProcessor = string =>
/* session processor */ /* session processor */
export const makeSessionSlugProcessor = (preserveUnicode = false) => { export const makeSessionSlugProcessor = (preserveUnicode = false) => {
const processor = preserveUnicode ? unicodeSafeProcessor : limaxProcessor; const processor = preserveUnicode ? unicodeSafeProcessor : urlsafeSlugProcessor;
const seen = new Set(); const seen = new Set();
return string => { return string => {

@ -1,61 +1,61 @@
import {strict as assert} from 'assert'; import {strict as assert} from 'assert';
import {limaxProcessor, unicodeSafeProcessor} from '../../src/utils/slug'; import {urlsafeSlugProcessor, unicodeSafeProcessor} from '../../src/utils/slug';
import {SLUG_SEPARATOR as _, SLUG_LANG} from '../../config'; import {SLUG_SEPARATOR as _} from '../../config';
describe('slug', () => { describe('slug', () => {
describe('limaxProcessor (latinize unicode)', () => { describe('urlsafeSlugProcessor', () => {
describe('ascii', () => { describe('ascii', () => {
it('space separated words', () => { it('space separated words', () => {
assert.equal( assert.equal(
limaxProcessor('Text expressions'), urlsafeSlugProcessor('Text expressions'),
`text${_}expressions` `Text${_}expressions`
); );
}); });
it('numbered text', () => { it('numbered text', () => {
assert.equal( assert.equal(
limaxProcessor('1. export creates'), urlsafeSlugProcessor('1. export creates'),
`1${_}export${_}creates` `1${_}export${_}creates`
); );
}); });
it('punctuated text', () => { it('punctuated text', () => {
assert.equal( assert.equal(
limaxProcessor('svelte.VERSION'), urlsafeSlugProcessor('svelte.VERSION'),
`svelte${_}version` `svelte${_}VERSION`
); );
}); });
it('text starting with the dollar sign', () => { it('text starting with the dollar sign', () => {
assert.equal( assert.equal(
limaxProcessor('$destroy method'), urlsafeSlugProcessor('$destroy method'),
`$destroy${_}method` `$destroy${_}method`
); );
}); });
it('numbered text containing the dollar sign', () => { it('numbered text containing the dollar sign', () => {
assert.equal( assert.equal(
limaxProcessor('1. export $destroy'), urlsafeSlugProcessor('1. export $destroy'),
`1${_}export${_}$destroy` `1${_}export${_}$destroy`
); );
}); });
it('text containing the equal char', () => { it('text containing the equal char', () => {
assert.equal( assert.equal(
limaxProcessor('script context=module'), urlsafeSlugProcessor('script context=module'),
`script${_}context${_}module` `script${_}context${_}module`
); );
}); });
it('text containing the colon char', () => { it('text containing the colon char', () => {
assert.equal( assert.equal(
limaxProcessor('svelte:body'), urlsafeSlugProcessor('svelte:body'),
`svelte${_}body` `svelte${_}body`
); );
}); });
it('text containing the slash char', () => { it('text containing the slash char', () => {
assert.equal( assert.equal(
limaxProcessor('svelte/motion'), urlsafeSlugProcessor('svelte/motion'),
`svelte${_}motion` `svelte${_}motion`
); );
}); });
it('text containing the comma char', () => { it('text containing the comma char', () => {
assert.equal( assert.equal(
limaxProcessor('svelte, motion'), urlsafeSlugProcessor('svelte, motion'),
`svelte${_}motion` `svelte${_}motion`
); );
}); });
@ -63,156 +63,150 @@ describe('slug', () => {
describe('unicode', () => { describe('unicode', () => {
it('should translate symbols to English', () => { it('should translate symbols to English', () => {
assert.equal( assert.equal(
limaxProcessor('Ich ♥ Deutsch'), urlsafeSlugProcessor('Ich ♥ Deutsch'),
`ich${_}love${_}deutsch` `Ich${_}love${_}Deutsch`
); );
}); });
it('should remove emoji', () => { it('should remove emoji', () => {
assert.equal( assert.equal(
limaxProcessor('Ich 😍 Deutsch'), urlsafeSlugProcessor('Ich 😍 Deutsch'),
`ich${_}deutsch` `Ich${_}Deutsch`
);
});
it('should translate symbols to the given language (German)', () => {
assert.equal(
limaxProcessor('Ich ♥ Deutsch', 'de'),
`ich${_}liebe${_}deutsch`
); );
}); });
}); });
describe('cyricllic', () => { describe('cyricllic', () => {
it('space separated words', () => { it('space separated words', () => {
assert.equal( assert.equal(
limaxProcessor('Всплытие и перехват событий'), urlsafeSlugProcessor('Всплытие и перехват событий'),
`vsplytie${_}i${_}perekhvat${_}sobytii` `Vsplytie${_}i${_}perehvat${_}sobytij`
); );
}); });
it('numbered text', () => { it('numbered text', () => {
assert.equal( assert.equal(
limaxProcessor('1 Всплытие и перехват событий'), urlsafeSlugProcessor('1 Всплытие и перехват событий'),
`1${_}vsplytie${_}i${_}perekhvat${_}sobytii` `1${_}Vsplytie${_}i${_}perehvat${_}sobytij`
); );
}); });
it('punctuated text', () => { it('punctuated text', () => {
assert.equal( assert.equal(
limaxProcessor('.Всплытие.и.перехват событий'), urlsafeSlugProcessor('.Всплытие.и.перехват событий'),
`vsplytie${_}i${_}perekhvat${_}sobytii` `Vsplytie${_}i${_}perehvat${_}sobytij`
); );
}); });
it('text starting with the dollar sign', () => { it('text starting with the dollar sign', () => {
assert.equal( assert.equal(
limaxProcessor('$Всплытие $ перехват событий'), urlsafeSlugProcessor('$Всплытие $ перехват событий'),
`$vsplytie${_}$${_}perekhvat${_}sobytii` `$Vsplytie${_}$${_}perehvat${_}sobytij`
); );
}); });
it('text containing the dollar sign', () => { it('text containing the dollar sign', () => {
assert.equal( assert.equal(
limaxProcessor('Всплытие$перехват'), urlsafeSlugProcessor('Всплытие$перехват'),
`vsplytie$perekhvat` `Vsplytie$perehvat`
); );
}); });
it('text containing the equal char', () => { it('text containing the equal char', () => {
assert.equal( assert.equal(
limaxProcessor('Всплытие = перехват=событий'), urlsafeSlugProcessor('Всплытие = перехват=событий'),
`vsplytie${_}perekhvat${_}sobytii` `Vsplytie${_}perehvat${_}sobytij`
); );
}); });
it('text containing the colon char', () => { it('text containing the colon char', () => {
assert.equal( assert.equal(
limaxProcessor('Всплытие : перехват:событий'), urlsafeSlugProcessor('Всплытие : перехват:событий'),
`vsplytie${_}perekhvat${_}sobytii` `Vsplytie${_}perehvat${_}sobytij`
); );
}); });
it('text containing the slash char', () => { it('text containing the slash char', () => {
assert.equal( assert.equal(
limaxProcessor('Всплытие / перехват/событий'), urlsafeSlugProcessor('Всплытие / перехват/событий'),
`vsplytie${_}perekhvat${_}sobytii` `Vsplytie${_}perehvat${_}sobytij`
); );
}); });
it('text containing the comma char', () => { it('text containing the comma char', () => {
assert.equal( assert.equal(
limaxProcessor('Всплытие, перехват'), urlsafeSlugProcessor('Всплытие, перехват'),
`vsplytie${_}perekhvat` `Vsplytie${_}perehvat`
); );
}); });
}); });
describe('ascii + cyricllic', () => { describe('ascii + cyricllic', () => {
it('space separated words', () => { it('space separated words', () => {
assert.equal( assert.equal(
limaxProcessor('Всплытие и export перехват событий'), urlsafeSlugProcessor('Всплытие и export перехват событий'),
`vsplytie${_}i${_}export${_}perekhvat${_}sobytii` `Vsplytie${_}i${_}export${_}perehvat${_}sobytij`
); );
}); });
it('ascii word concatenated to a cyricllic word', () => { it('ascii word concatenated to a cyricllic word', () => {
assert.equal( assert.equal(
limaxProcessor('exportВсплытие'), urlsafeSlugProcessor('exportВсплытие'),
'exportvsplytie' 'exportVsplytie'
); );
}); });
it('cyricllic word concatenated to an ascii word', () => { it('cyricllic word concatenated to an ascii word', () => {
assert.equal( assert.equal(
limaxProcessor('Всплытиеexport'), urlsafeSlugProcessor('Всплытиеexport'),
`vsplytieexport` `Vsplytieexport`
); );
}); });
it('numbered text', () => { it('numbered text', () => {
assert.equal( assert.equal(
limaxProcessor('1 export Всплытие и перехват событий'), urlsafeSlugProcessor('1 export Всплытие и перехват событий'),
`1${_}export${_}vsplytie${_}i${_}perekhvat${_}sobytii` `1${_}export${_}Vsplytie${_}i${_}perehvat${_}sobytij`
); );
}); });
it('punctuated text', () => { it('punctuated text', () => {
assert.equal( assert.equal(
limaxProcessor('.Всплытие.export.и.перехват событий'), urlsafeSlugProcessor('.Всплытие.export.и.перехват событий'),
`vsplytie${_}export${_}i${_}perekhvat${_}sobytii` `Vsplytie${_}export${_}i${_}perehvat${_}sobytij`
); );
}); });
it('text starting with the dollar sign, followed by ascii char', () => { it('text starting with the dollar sign, followed by ascii char', () => {
assert.equal( assert.equal(
limaxProcessor('$exportВсплытие перехват событий'), urlsafeSlugProcessor('$exportВсплытие перехват событий'),
`$exportvsplytie${_}perekhvat${_}sobytii` `$exportVsplytie${_}perehvat${_}sobytij`
); );
}); });
it('text starting with the dollar sign, followed by unicode char', () => { it('text starting with the dollar sign, followed by unicode char', () => {
assert.equal( assert.equal(
limaxProcessor('$Всплытие export перехват событий'), urlsafeSlugProcessor('$Всплытие export перехват событий'),
`$vsplytie${_}export${_}perekhvat${_}sobytii` `$Vsplytie${_}export${_}perehvat${_}sobytij`
); );
}); });
it('text containing the dollar sign, followed by ascii char', () => { it('text containing the dollar sign, followed by ascii char', () => {
assert.equal( assert.equal(
limaxProcessor('export $destroy a component prop Всплытие и перехват событий'), urlsafeSlugProcessor('export $destroy a component prop Всплытие и перехват событий'),
`export${_}$destroy${_}a${_}component${_}prop${_}vsplytie${_}i${_}perekhvat${_}sobytii` `export${_}$destroy${_}a${_}component${_}prop${_}Vsplytie${_}i${_}perehvat${_}sobytij`
); );
}); });
it('text containing the dollar sign, followed by unicode char', () => { it('text containing the dollar sign, followed by unicode char', () => {
assert.equal( assert.equal(
limaxProcessor('Всплытие export $Всплытие a component prop Всплытие и перехват событий'), urlsafeSlugProcessor('Всплытие export $Всплытие a component prop Всплытие и перехват событий'),
`vsplytie${_}export${_}$vsplytie${_}a${_}component${_}prop${_}vsplytie${_}i${_}perekhvat${_}sobytii` `Vsplytie${_}export${_}$Vsplytie${_}a${_}component${_}prop${_}Vsplytie${_}i${_}perehvat${_}sobytij`
); );
}); });
it('text containing the equal char', () => { it('text containing the equal char', () => {
assert.equal( assert.equal(
limaxProcessor('script context=module Всплытие=и перехват событий'), urlsafeSlugProcessor('script context=module Всплытие=и перехват событий'),
`script${_}context${_}module${_}vsplytie${_}i${_}perekhvat${_}sobytii` `script${_}context${_}module${_}Vsplytie${_}i${_}perehvat${_}sobytij`
); );
}); });
it('text containing the colon char', () => { it('text containing the colon char', () => {
assert.equal( assert.equal(
limaxProcessor('svelte:body Всплытие и:перехват событий'), urlsafeSlugProcessor('svelte:body Всплытие и:перехват событий'),
`svelte${_}body${_}vsplytie${_}i${_}perekhvat${_}sobytii` `svelte${_}body${_}Vsplytie${_}i${_}perehvat${_}sobytij`
); );
}); });
it('text containing the slash char', () => { it('text containing the slash char', () => {
assert.equal( assert.equal(
limaxProcessor('svelte/motion Всплытие и / перехват/событий'), urlsafeSlugProcessor('svelte/motion Всплытие и / перехват/событий'),
`svelte${_}motion${_}vsplytie${_}i${_}perekhvat${_}sobytii` `svelte${_}motion${_}Vsplytie${_}i${_}perehvat${_}sobytij`
); );
}); });
it('text containing the comma char', () => { it('text containing the comma char', () => {
assert.equal( assert.equal(
limaxProcessor('Всплытие, export'), urlsafeSlugProcessor('Всплытие, export'),
`vsplytie${_}export` `Vsplytie${_}export`
); );
}); });
}); });
@ -223,7 +217,7 @@ describe('slug', () => {
it('space separated words', () => { it('space separated words', () => {
assert.equal( assert.equal(
unicodeSafeProcessor('Text expressions'), unicodeSafeProcessor('Text expressions'),
`text${_}expressions` `Text${_}expressions`
); );
}); });
it('numbered text', () => { it('numbered text', () => {
@ -235,7 +229,7 @@ describe('slug', () => {
it('punctuated text', () => { it('punctuated text', () => {
assert.equal( assert.equal(
unicodeSafeProcessor('svelte.VERSION'), unicodeSafeProcessor('svelte.VERSION'),
`svelte${_}version` `svelte${_}VERSION`
); );
}); });
it('text starting with the dollar sign', () => { it('text starting with the dollar sign', () => {
@ -279,13 +273,13 @@ describe('slug', () => {
it('should preserve symbols', () => { it('should preserve symbols', () => {
assert.equal( assert.equal(
unicodeSafeProcessor('Ich ♥ Deutsch'), unicodeSafeProcessor('Ich ♥ Deutsch'),
`ich${_}love${_}deutsch` `Ich${_}love${_}Deutsch`
); );
}); });
it('should remove emoji', () => { it('should remove emoji', () => {
assert.equal( assert.equal(
unicodeSafeProcessor('Ich 😍 Deutsch'), unicodeSafeProcessor('Ich 😍 Deutsch'),
`ich${_}deutsch` `Ich${_}Deutsch`
); );
}); });
}); });

Loading…
Cancel
Save