File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export function slugify(str) {
15
15
let slug = str
16
16
. trim ( )
17
17
. replace ( / [ A - Z ] + / g, lower )
18
- . replace ( / < [ ^ > \d ] + > / g, '' )
18
+ . replace ( / < [ ^ > ] + > / g, '' )
19
19
. replace ( re , '' )
20
20
. replace ( / \s / g, '-' )
21
21
. replace ( / - + / g, '-' )
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ const { removeAtag } = require('../../src/core/render/utils');
2
2
3
3
const { tree } = require ( `../../src/core/render/tpl` ) ;
4
4
5
+ const { slugify } = require ( `../../src/core/render/slugify` ) ;
6
+
5
7
// Suite
6
8
// -----------------------------------------------------------------------------
7
9
describe ( 'core/render/utils' , ( ) => {
@@ -42,3 +44,16 @@ describe('core/render/tpl', () => {
42
44
) ;
43
45
} ) ;
44
46
} ) ;
47
+
48
+ describe ( 'core/render/slugify' , ( ) => {
49
+ test ( 'slugify()' , ( ) => {
50
+ const result = slugify (
51
+ `Bla bla bla <svg aria-label="broken" class="broken" viewPort="0 0 1 1"><circle cx="0.5" cy="0.5"/></svg>`
52
+ ) ;
53
+ const result2 = slugify (
54
+ `Another <span style="font-size: 1.2em" class="foo bar baz">broken <span class="aaa">example</span></span>`
55
+ ) ;
56
+ expect ( result ) . toEqual ( `bla-bla-bla-` ) ;
57
+ expect ( result2 ) . toEqual ( `another-broken-example` ) ;
58
+ } ) ;
59
+ } ) ;
You can’t perform that action at this time.
0 commit comments