1 | // Shamelessly copied from nico:
|
2 | // https://github.com/lepture/nico/blob/master/lib/sdk/encode.js
|
3 | ;
|
4 |
|
5 | exports.uri = function(text) {
|
6 | text = text.replace(/<\/?[^>]*>/g, '');
|
7 | var regex = /[^,\.<>\/\?;\:'"\[\]\{\}\\\|`~!@#\$%\^\&\*\(\)\_\+\=\s]+/g;
|
8 | var bits = text.match(regex);
|
9 | if (bits) {
|
10 | text = bits.join('-').toLowerCase();
|
11 | }
|
12 | text = text.replace(/-{2,}/g, '-');
|
13 | return text;
|
14 | }; |
\ | No newline at end of file |