WXL
2025-12-19 da459f4addc08dede5b91f1f4e87e6c1c6d3c88e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
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();
    });
 
});