File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 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) {
1515 let slug = str
1616 . trim ( )
1717 . replace ( / [ A - Z ] + / g, lower )
18- . replace ( / < [ ^ > \d ] + > / g, '' )
18+ . replace ( / < [ ^ > ] + > / g, '' )
1919 . replace ( re , '' )
2020 . replace ( / \s / g, '-' )
2121 . replace ( / - + / g, '-' )
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ const { removeAtag } = require('../../src/core/render/utils');
22
33const { tree } = require ( `../../src/core/render/tpl` ) ;
44
5+ const { slugify } = require ( `../../src/core/render/slugify` ) ;
6+
57// Suite
68// -----------------------------------------------------------------------------
79describe ( 'core/render/utils' , ( ) => {
@@ -42,3 +44,16 @@ describe('core/render/tpl', () => {
4244 ) ;
4345 } ) ;
4446} ) ;
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