speakingurl-rails 4.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -5
- data/lib/speakingurl.js +183 -131
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55e3b189f005f070ead1c169b8fc1173b7fbea41
|
4
|
+
data.tar.gz: 46c77f1df5444d5069a365d877ec8dd6fe15bbfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9c5a52250a2edfb37393d841f49e2d93c48a4a4342f2e22f22da24fc06494eec50366bf581f23ab4b14b15f3d507d592131b60d1ca11724ed5609ba9179c20d
|
7
|
+
data.tar.gz: 6e4eae4f5dd08e4dea7c555f9ae7f800adf0d2bc551e53468c1726ec6378d81ada2bb7635afcc8eb90366d055122a3b0674e7c43492af4a4f08f8b85446aa926
|
data/README.md
CHANGED
@@ -58,14 +58,14 @@ copy the file speakingurl.min.js to your script directory
|
|
58
58
|
available versions:
|
59
59
|
|
60
60
|
- [www.cdnjs.com/libraries/speakingurl/](http://cdnjs.com/libraries/speakingurl/)
|
61
|
-
- use [//cdnjs.cloudflare.com/ajax/libs/speakingurl/
|
61
|
+
- use [//cdnjs.cloudflare.com/ajax/libs/speakingurl/5.0.0/speakingurl.min.js](https://cdnjs.cloudflare.com/ajax/libs/speakingurl/5.0.0/speakingurl.min.js)
|
62
62
|
|
63
63
|
#### [CDN/maxcdn](https://www.maxcdn.com/)
|
64
64
|
|
65
65
|
available versions:
|
66
66
|
|
67
67
|
- [www.jsdelivr.com/#!speakingurl](]http://www.jsdelivr.com/#!speakingurl)
|
68
|
-
- use [//cdn.jsdelivr.net/speakingurl/
|
68
|
+
- use [//cdn.jsdelivr.net/speakingurl/5.0.0/speakingurl.min.js](https://cdn.jsdelivr.net/speakingurl/5.0.0/speakingurl.min.js)
|
69
69
|
|
70
70
|
Usage
|
71
71
|
-----
|
@@ -80,9 +80,33 @@ Usage
|
|
80
80
|
|
81
81
|
- `separator` {string} default: '-'
|
82
82
|
- char that replace the whitespaces
|
83
|
-
- `lang` {string} default: 'en'
|
84
|
-
- language specific transliteration (
|
85
|
-
|
83
|
+
- `lang` {string} default: 'en' // ISO 639-1 Codes
|
84
|
+
- language specific transliteration (
|
85
|
+
- 'ar' // Arabic
|
86
|
+
- 'az' // Azerbaijani\*
|
87
|
+
- 'cs' // Czech
|
88
|
+
- 'de' // German
|
89
|
+
- 'en' // English
|
90
|
+
- 'es' // Spanish
|
91
|
+
- 'fr' // French
|
92
|
+
- 'gr' // Greek\*
|
93
|
+
- 'hu' // Hungarian
|
94
|
+
- 'it' // Italian
|
95
|
+
- 'lt' // Lithuanian\*
|
96
|
+
- 'lv' // Latvian
|
97
|
+
- 'my' // Burmese
|
98
|
+
- 'mk' // Macedonian\*
|
99
|
+
- 'nl' // Dutch
|
100
|
+
- 'pl' // Polish
|
101
|
+
- 'pt' // Portuguese
|
102
|
+
- 'ro' // Romanian
|
103
|
+
- 'ru' // Russian
|
104
|
+
- 'sk' // Slovak
|
105
|
+
- 'sr' // Serbian\*
|
106
|
+
- 'tr' // Turkish
|
107
|
+
- 'uk' // Ukranian
|
108
|
+
- 'vn' // Vietnamese
|
109
|
+
- `symbols` {boolean} default: true
|
86
110
|
- false -> don't convert symbols
|
87
111
|
- true -> convert symbols according to the 'lang' setting
|
88
112
|
- `maintainCase` {boolean} default: false
|
@@ -241,6 +265,17 @@ slug = getSlug('Foo & Bar ♥ Foo < Bar', {
|
|
241
265
|
lang: false
|
242
266
|
});
|
243
267
|
console.log(slug); // Output: foo-bar-foo-bar
|
268
|
+
|
269
|
+
slug = getSlug('Foo & Bar ♥ Foo < Bar', {
|
270
|
+
symbols: false
|
271
|
+
});
|
272
|
+
console.log(slug); // Output: foo-bar-foo-bar
|
273
|
+
|
274
|
+
slug = getSlug('ä♥ä', {
|
275
|
+
lang: 'tr',
|
276
|
+
symbols: false
|
277
|
+
});
|
278
|
+
console.log(slug); // Output: a
|
244
279
|
```
|
245
280
|
|
246
281
|
### createSlug([options])
|
data/lib/speakingurl.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
(function (root) {
|
1
|
+
(function (root, undefined) {
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
/**
|
@@ -10,29 +10,29 @@
|
|
10
10
|
*/
|
11
11
|
var getSlug = function getSlug(input, opts) {
|
12
12
|
|
13
|
-
var
|
14
|
-
var titleCase;
|
15
|
-
var customReplacements = (typeof opts === 'object' && typeof opts.custom === 'object' && opts.custom) ? opts.custom : {};
|
16
|
-
var separator = (typeof opts === 'object' && opts.separator) || '-';
|
17
|
-
var truncate = (typeof opts === 'object' && +opts.truncate > 1 && opts.truncate) || false;
|
18
|
-
var uricFlag = (typeof opts === 'object' && opts.uric) || false;
|
19
|
-
var uricNoSlashFlag = (typeof opts === 'object' && opts.uricNoSlash) || false;
|
20
|
-
var markFlag = (typeof opts === 'object' && opts.mark) || false;
|
21
|
-
var convertSymbols = (typeof opts === 'object' && (opts.symbols === false || opts.lang === false)) ? false : true;
|
22
|
-
var symbol;
|
23
|
-
var langChar;
|
13
|
+
var separator = '-';
|
24
14
|
var uricChars = [';', '?', ':', '@', '&', '=', '+', '$', ',', '/'];
|
25
15
|
var uricNoSlashChars = [';', '?', ':', '@', '&', '=', '+', '$', ','];
|
26
16
|
var markChars = ['.', '!', '~', '*', '\'', '(', ')'];
|
27
17
|
var result = '';
|
28
18
|
var diatricString = '';
|
19
|
+
var convertSymbols = true;
|
20
|
+
var customReplacements = {};
|
21
|
+
var maintainCase;
|
22
|
+
var titleCase;
|
23
|
+
var truncate;
|
24
|
+
var uricFlag;
|
25
|
+
var uricNoSlashFlag;
|
26
|
+
var markFlag;
|
27
|
+
var symbol;
|
28
|
+
var langChar;
|
29
29
|
var lucky;
|
30
|
-
var allowedChars = separator;
|
31
30
|
var i;
|
32
31
|
var ch;
|
33
32
|
var l;
|
34
33
|
var lastCharWasSymbol;
|
35
34
|
var lastCharWasDiatric;
|
35
|
+
var allowedChars;
|
36
36
|
|
37
37
|
/**
|
38
38
|
* charMap
|
@@ -174,7 +174,7 @@
|
|
174
174
|
'٨': '8',
|
175
175
|
'٩': '9',
|
176
176
|
|
177
|
-
//
|
177
|
+
// Burmese consonants
|
178
178
|
'က': 'k',
|
179
179
|
'ခ': 'kh',
|
180
180
|
'ဂ': 'g',
|
@@ -241,7 +241,7 @@
|
|
241
241
|
'့': '',
|
242
242
|
'း': '',
|
243
243
|
|
244
|
-
//
|
244
|
+
// Czech
|
245
245
|
'č': 'c',
|
246
246
|
'ď': 'd',
|
247
247
|
'ě': 'e',
|
@@ -261,7 +261,7 @@
|
|
261
261
|
'Ů': 'U',
|
262
262
|
'Ž': 'Z',
|
263
263
|
|
264
|
-
//
|
264
|
+
// Greek
|
265
265
|
'α': 'a',
|
266
266
|
'β': 'v',
|
267
267
|
'γ': 'g',
|
@@ -332,7 +332,7 @@
|
|
332
332
|
'Ϊ': 'I',
|
333
333
|
'Ϋ': 'Y',
|
334
334
|
|
335
|
-
//
|
335
|
+
// Latvian
|
336
336
|
'ā': 'a',
|
337
337
|
// 'č': 'c', // duplicate
|
338
338
|
'ē': 'e',
|
@@ -356,7 +356,7 @@
|
|
356
356
|
'Ū': 'U',
|
357
357
|
// 'Ž': 'Z', // duplicate
|
358
358
|
|
359
|
-
//
|
359
|
+
// Macedonian
|
360
360
|
'Ќ': 'Kj',
|
361
361
|
'ќ': 'kj',
|
362
362
|
'Љ': 'Lj',
|
@@ -366,7 +366,7 @@
|
|
366
366
|
'Тс': 'Ts',
|
367
367
|
'тс': 'ts',
|
368
368
|
|
369
|
-
//
|
369
|
+
// Polish
|
370
370
|
'ą': 'a',
|
371
371
|
'ć': 'c',
|
372
372
|
'ę': 'e',
|
@@ -385,7 +385,7 @@
|
|
385
385
|
'Ź': 'Z',
|
386
386
|
'Ż': 'Z',
|
387
387
|
|
388
|
-
//
|
388
|
+
// Ukranian
|
389
389
|
'Є': 'Ye',
|
390
390
|
'І': 'I',
|
391
391
|
'Ї': 'Yi',
|
@@ -407,7 +407,7 @@
|
|
407
407
|
'ţ': 't',
|
408
408
|
'Ţ': 'T',
|
409
409
|
|
410
|
-
//
|
410
|
+
// Russian
|
411
411
|
'а': 'a',
|
412
412
|
'б': 'b',
|
413
413
|
'в': 'v',
|
@@ -475,7 +475,7 @@
|
|
475
475
|
'Ю': 'Yu',
|
476
476
|
'Я': 'Ya',
|
477
477
|
|
478
|
-
//
|
478
|
+
// Serbian
|
479
479
|
'ђ': 'dj',
|
480
480
|
'ј': 'j',
|
481
481
|
// 'љ': 'lj', // duplicate
|
@@ -489,7 +489,7 @@
|
|
489
489
|
'Ћ': 'C',
|
490
490
|
'Џ': 'Dz',
|
491
491
|
|
492
|
-
//
|
492
|
+
// Slovak
|
493
493
|
'ľ': 'l',
|
494
494
|
'ĺ': 'l',
|
495
495
|
'ŕ': 'r',
|
@@ -497,7 +497,7 @@
|
|
497
497
|
'Ĺ': 'L',
|
498
498
|
'Ŕ': 'R',
|
499
499
|
|
500
|
-
//
|
500
|
+
// Turkish
|
501
501
|
'ş': 's',
|
502
502
|
'Ş': 'S',
|
503
503
|
'ı': 'i',
|
@@ -683,7 +683,7 @@
|
|
683
683
|
* @type {Object}
|
684
684
|
*/
|
685
685
|
var diatricMap = {
|
686
|
-
//
|
686
|
+
// Burmese
|
687
687
|
// dependent vowels
|
688
688
|
'ာ': 'a',
|
689
689
|
'ါ': 'a',
|
@@ -743,21 +743,24 @@
|
|
743
743
|
* @type {Object}
|
744
744
|
*/
|
745
745
|
var langCharMap = {
|
746
|
+
|
746
747
|
'en': {}, // default language
|
747
748
|
|
748
|
-
'
|
749
|
-
'
|
750
|
-
'
|
751
|
-
|
752
|
-
|
753
|
-
'ö': 'o',
|
754
|
-
'
|
755
|
-
// 'ő': 'o', duplicate see charMap/latin
|
756
|
-
// 'Ő': 'O', duplicate see charMap/latin
|
749
|
+
'az': { // Azerbaijani
|
750
|
+
'ç': 'c',
|
751
|
+
'ə': 'e',
|
752
|
+
'ğ': 'g',
|
753
|
+
'ı': 'i',
|
754
|
+
'ö': 'o',
|
755
|
+
'ş': 's',
|
757
756
|
'ü': 'u',
|
758
|
-
'
|
759
|
-
'
|
760
|
-
'
|
757
|
+
'Ç': 'C',
|
758
|
+
'Ə': 'E',
|
759
|
+
'Ğ': 'G',
|
760
|
+
'İ': 'I',
|
761
|
+
'Ö': 'O',
|
762
|
+
'Ş': 'S',
|
763
|
+
'Ü': 'U'
|
761
764
|
},
|
762
765
|
|
763
766
|
'cs': { // Czech
|
@@ -781,30 +784,39 @@
|
|
781
784
|
'Ž': 'Z'
|
782
785
|
},
|
783
786
|
|
784
|
-
'
|
787
|
+
'hu': { // Hungarian
|
788
|
+
'ä': 'a', // ok
|
789
|
+
'Ä': 'A', // ok
|
790
|
+
// 'á': 'a', duplicate see charMap/latin
|
791
|
+
// 'Á': 'A', duplicate see charMap/latin
|
792
|
+
'ö': 'o', // ok
|
793
|
+
'Ö': 'O', // ok
|
794
|
+
// 'ő': 'o', duplicate see charMap/latin
|
795
|
+
// 'Ő': 'O', duplicate see charMap/latin
|
796
|
+
'ü': 'u',
|
797
|
+
'Ü': 'U',
|
798
|
+
'ű': 'u',
|
799
|
+
'Ű': 'U'
|
800
|
+
},
|
801
|
+
|
802
|
+
'lt': { // Lithuanian
|
785
803
|
'ą': 'a',
|
786
|
-
'
|
804
|
+
'č': 'c',
|
787
805
|
'ę': 'e',
|
788
|
-
'
|
789
|
-
'
|
790
|
-
'
|
791
|
-
'
|
792
|
-
'
|
793
|
-
'
|
806
|
+
'ė': 'e',
|
807
|
+
'į': 'i',
|
808
|
+
'š': 's',
|
809
|
+
'ų': 'u',
|
810
|
+
'ū': 'u',
|
811
|
+
'ž': 'z',
|
794
812
|
'Ą': 'A',
|
795
|
-
'
|
796
|
-
'Ę': '
|
797
|
-
'
|
798
|
-
'
|
799
|
-
'
|
800
|
-
'
|
801
|
-
'
|
802
|
-
'Ż': 'Z'
|
803
|
-
},
|
804
|
-
|
805
|
-
'sk': {
|
806
|
-
'ä': 'a',
|
807
|
-
'Ä': 'A'
|
813
|
+
'Č': 'C',
|
814
|
+
'Ę': 'E',
|
815
|
+
'Ė': 'E',
|
816
|
+
'Į': 'I',
|
817
|
+
'Š': 'S',
|
818
|
+
'Ų': 'U',
|
819
|
+
'Ū': 'U'
|
808
820
|
},
|
809
821
|
|
810
822
|
'lv': { // Latvian
|
@@ -832,24 +844,30 @@
|
|
832
844
|
'Ž': 'Z'
|
833
845
|
},
|
834
846
|
|
835
|
-
'
|
847
|
+
'pl': { // Polish
|
836
848
|
'ą': 'a',
|
837
|
-
'
|
849
|
+
'ć': 'c',
|
838
850
|
'ę': 'e',
|
839
|
-
'
|
840
|
-
'
|
841
|
-
'
|
842
|
-
'
|
843
|
-
'
|
844
|
-
'
|
851
|
+
'ł': 'l',
|
852
|
+
'ń': 'n',
|
853
|
+
'ó': 'o',
|
854
|
+
'ś': 's',
|
855
|
+
'ź': 'z',
|
856
|
+
'ż': 'z',
|
845
857
|
'Ą': 'A',
|
846
|
-
'
|
847
|
-
'Ę': '
|
848
|
-
'
|
849
|
-
'
|
850
|
-
'
|
851
|
-
'
|
852
|
-
'
|
858
|
+
'Ć': 'C',
|
859
|
+
'Ę': 'e',
|
860
|
+
'Ł': 'L',
|
861
|
+
'Ń': 'N',
|
862
|
+
'Ó': 'O',
|
863
|
+
'Ś': 'S',
|
864
|
+
'Ź': 'Z',
|
865
|
+
'Ż': 'Z'
|
866
|
+
},
|
867
|
+
|
868
|
+
'sk': { // Slovak
|
869
|
+
'ä': 'a',
|
870
|
+
'Ä': 'A'
|
853
871
|
},
|
854
872
|
|
855
873
|
'sr': { // Serbian
|
@@ -861,23 +879,6 @@
|
|
861
879
|
'Đ': 'Dj'
|
862
880
|
},
|
863
881
|
|
864
|
-
'az': { // Azerbaijani
|
865
|
-
'ç': 'c',
|
866
|
-
'ə': 'e',
|
867
|
-
'ğ': 'g',
|
868
|
-
'ı': 'i',
|
869
|
-
'ö': 'o',
|
870
|
-
'ş': 's',
|
871
|
-
'ü': 'u',
|
872
|
-
'Ç': 'C',
|
873
|
-
'Ə': 'E',
|
874
|
-
'Ğ': 'G',
|
875
|
-
'İ': 'I',
|
876
|
-
'Ö': 'O',
|
877
|
-
'Ş': 'S',
|
878
|
-
'Ü': 'U'
|
879
|
-
},
|
880
|
-
|
881
882
|
'tr': { // Turkish
|
882
883
|
'Ü': 'U',
|
883
884
|
'Ö': 'O',
|
@@ -905,6 +906,8 @@
|
|
905
906
|
'¤': 'omla'
|
906
907
|
},
|
907
908
|
|
909
|
+
'az': {},
|
910
|
+
|
908
911
|
'cz': {
|
909
912
|
'∆': 'delta',
|
910
913
|
'∞': 'nekonecno',
|
@@ -965,6 +968,8 @@
|
|
965
968
|
'¤': 'monnaie'
|
966
969
|
},
|
967
970
|
|
971
|
+
'gr': {},
|
972
|
+
|
968
973
|
'hu': {
|
969
974
|
'∆': 'delta',
|
970
975
|
'∞': 'vegtelen',
|
@@ -989,6 +994,20 @@
|
|
989
994
|
'¤': 'moneta'
|
990
995
|
},
|
991
996
|
|
997
|
+
'lt': {},
|
998
|
+
|
999
|
+
'lv': {
|
1000
|
+
'∆': 'delta',
|
1001
|
+
'∞': 'bezgaliba',
|
1002
|
+
'♥': 'milestiba',
|
1003
|
+
'&': 'un',
|
1004
|
+
'|': 'vai',
|
1005
|
+
'<': 'mazak neka',
|
1006
|
+
'>': 'lielaks neka',
|
1007
|
+
'∑': 'summa',
|
1008
|
+
'¤': 'valuta'
|
1009
|
+
},
|
1010
|
+
|
992
1011
|
'my': {
|
993
1012
|
'∆': 'kwahkhyaet',
|
994
1013
|
'∞': 'asaonasme',
|
@@ -1001,6 +1020,8 @@
|
|
1001
1020
|
'¤': 'ngwekye'
|
1002
1021
|
},
|
1003
1022
|
|
1023
|
+
'mk': {},
|
1024
|
+
|
1004
1025
|
'nl': {
|
1005
1026
|
'∆': 'delta',
|
1006
1027
|
'∞': 'oneindig',
|
@@ -1073,6 +1094,8 @@
|
|
1073
1094
|
'¤': 'mena'
|
1074
1095
|
},
|
1075
1096
|
|
1097
|
+
'sr': {},
|
1098
|
+
|
1076
1099
|
'tr': {
|
1077
1100
|
'∆': 'delta',
|
1078
1101
|
'∞': 'sonsuzluk',
|
@@ -1085,6 +1108,18 @@
|
|
1085
1108
|
'¤': 'para birimi'
|
1086
1109
|
},
|
1087
1110
|
|
1111
|
+
'uk': {
|
1112
|
+
'∆': 'delta',
|
1113
|
+
'∞': 'bezkinechnist',
|
1114
|
+
'♥': 'lubov',
|
1115
|
+
'&': 'i',
|
1116
|
+
'|': 'abo',
|
1117
|
+
'<': 'menshe',
|
1118
|
+
'>': 'bilshe',
|
1119
|
+
'∑': 'suma',
|
1120
|
+
'¤': 'valjuta'
|
1121
|
+
},
|
1122
|
+
|
1088
1123
|
'vn': {
|
1089
1124
|
'∆': 'delta',
|
1090
1125
|
'∞': 'vo cuc',
|
@@ -1098,39 +1133,27 @@
|
|
1098
1133
|
}
|
1099
1134
|
};
|
1100
1135
|
|
1101
|
-
symbol = (typeof opts === 'object' && opts.lang && symbolMap[opts.lang] && convertSymbols) ?
|
1102
|
-
symbolMap[opts.lang] : (convertSymbols ? symbolMap.en : {});
|
1103
|
-
|
1104
|
-
langChar = (typeof opts === 'object' && opts.lang && langCharMap[opts.lang]) ?
|
1105
|
-
langCharMap[opts.lang] : (typeof opts === 'object' && (opts.lang === false || opts.lang === true) ? {} : langCharMap.en);
|
1106
|
-
|
1107
|
-
// if titleCase config is an Array, rewrite to object format
|
1108
|
-
if (typeof opts === 'object' && opts.titleCase && typeof opts.titleCase.length === "number" && Array.prototype.toString.call(opts.titleCase)) {
|
1109
|
-
|
1110
|
-
opts.titleCase.forEach(function (v) {
|
1111
|
-
customReplacements[v + ""] = v + "";
|
1112
|
-
});
|
1113
|
-
|
1114
|
-
titleCase = true;
|
1115
|
-
} else {
|
1116
|
-
titleCase = typeof opts === 'object' && !!opts.titleCase;
|
1117
|
-
}
|
1118
|
-
|
1119
|
-
// if custom config is an Array, rewrite to object format
|
1120
|
-
if (typeof opts === 'object' && opts.custom && typeof opts.custom.length === "number" && Array.prototype.toString.call(opts.custom)) {
|
1121
|
-
|
1122
|
-
opts.custom.forEach(function (v) {
|
1123
|
-
customReplacements[v + ""] = v + "";
|
1124
|
-
});
|
1125
|
-
}
|
1126
|
-
|
1127
1136
|
if (typeof input !== 'string') {
|
1128
1137
|
return '';
|
1129
1138
|
}
|
1130
1139
|
|
1131
1140
|
if (typeof opts === 'string') {
|
1132
1141
|
separator = opts;
|
1133
|
-
}
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
symbol = symbolMap.en;
|
1145
|
+
langChar = langCharMap.en;
|
1146
|
+
|
1147
|
+
if (typeof opts === 'object') {
|
1148
|
+
|
1149
|
+
maintainCase = opts.maintainCase || false;
|
1150
|
+
customReplacements = (opts.custom && typeof opts.custom === 'object') ? opts.custom : customReplacements;
|
1151
|
+
truncate = (+opts.truncate > 1 && opts.truncate) || false;
|
1152
|
+
uricFlag = opts.uric || false;
|
1153
|
+
uricNoSlashFlag = opts.uricNoSlash || false;
|
1154
|
+
markFlag = opts.mark || false;
|
1155
|
+
convertSymbols = (opts.symbols === false || opts.lang === false) ? false : true;
|
1156
|
+
separator = opts.separator || separator;
|
1134
1157
|
|
1135
1158
|
if (uricFlag) {
|
1136
1159
|
allowedChars += uricChars.join('');
|
@@ -1143,28 +1166,57 @@
|
|
1143
1166
|
if (markFlag) {
|
1144
1167
|
allowedChars += markChars.join('');
|
1145
1168
|
}
|
1146
|
-
}
|
1147
1169
|
|
1148
|
-
|
1149
|
-
|
1170
|
+
symbol = (opts.lang && symbolMap[opts.lang] && convertSymbols) ?
|
1171
|
+
symbolMap[opts.lang] : (convertSymbols ? symbolMap.en : {});
|
1172
|
+
|
1173
|
+
langChar = (opts.lang && langCharMap[opts.lang]) ?
|
1174
|
+
langCharMap[opts.lang] :
|
1175
|
+
opts.lang === false || opts.lang === true ? {} : langCharMap.en;
|
1150
1176
|
|
1151
|
-
|
1177
|
+
// if titleCase config is an Array, rewrite to object format
|
1178
|
+
if (opts.titleCase && typeof opts.titleCase.length === "number" && Array.prototype.toString.call(opts.titleCase)) {
|
1152
1179
|
|
1153
|
-
|
1154
|
-
|
1180
|
+
opts.titleCase.forEach(function (v) {
|
1181
|
+
customReplacements[v + ""] = v + "";
|
1182
|
+
});
|
1183
|
+
|
1184
|
+
titleCase = true;
|
1155
1185
|
} else {
|
1156
|
-
|
1186
|
+
titleCase = !!opts.titleCase;
|
1157
1187
|
}
|
1158
1188
|
|
1159
|
-
|
1160
|
-
|
1189
|
+
// if custom config is an Array, rewrite to object format
|
1190
|
+
if (opts.custom && typeof opts.custom.length === "number" && Array.prototype.toString.call(opts.custom)) {
|
1161
1191
|
|
1162
|
-
|
1192
|
+
opts.custom.forEach(function (v) {
|
1193
|
+
customReplacements[v + ""] = v + "";
|
1194
|
+
});
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
// custom replacements
|
1198
|
+
Object.keys(customReplacements).forEach(function (v) {
|
1199
|
+
|
1200
|
+
var r;
|
1201
|
+
|
1202
|
+
if (v.length > 1) {
|
1203
|
+
r = new RegExp('\\b' + escapeChars(v) + '\\b', 'gi');
|
1204
|
+
} else {
|
1205
|
+
r = new RegExp(escapeChars(v), 'gi');
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
input = input.replace(r, customReplacements[v]);
|
1209
|
+
});
|
1210
|
+
|
1211
|
+
// add all custom replacement to allowed charlist
|
1212
|
+
for (ch in customReplacements) {
|
1213
|
+
allowedChars += ch;
|
1214
|
+
}
|
1163
1215
|
|
1164
|
-
for (ch in customReplacements) {
|
1165
|
-
allowedChars += ch;
|
1166
1216
|
}
|
1167
1217
|
|
1218
|
+
allowedChars += separator;
|
1219
|
+
|
1168
1220
|
if (titleCase) {
|
1169
1221
|
|
1170
1222
|
input = input.replace(/(\w)(\S*)/g, function (_, i, r) {
|
@@ -1308,13 +1360,13 @@
|
|
1308
1360
|
}
|
1309
1361
|
};
|
1310
1362
|
|
1311
|
-
if (typeof module !==
|
1363
|
+
if (typeof module !== undefined && module.exports) {
|
1312
1364
|
|
1313
1365
|
// export functions for use in Node
|
1314
1366
|
module.exports = getSlug;
|
1315
1367
|
module.exports.createSlug = createSlug;
|
1316
1368
|
|
1317
|
-
} else if (typeof define !==
|
1369
|
+
} else if (typeof define !== undefined && define.amd) {
|
1318
1370
|
|
1319
1371
|
// export function for use in AMD
|
1320
1372
|
define([], function () {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: speakingurl-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sascha Droste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|