@ -1,61 +1,61 @@
import { strict as assert } from 'assert' ;
import { strict as assert } from 'assert' ;
import { limax Processor, unicodeSafeProcessor } from '../../src/utils/slug' ;
import { urlsafeSlug Processor, unicodeSafeProcessor } from '../../src/utils/slug' ;
import { SLUG _SEPARATOR as _ , SLUG _LANG } from '../../config' ;
import { SLUG _SEPARATOR as _ } from '../../config' ;
describe ( 'slug' , ( ) => {
describe ( 'slug' , ( ) => {
describe ( ' limaxProcessor (latinize unicode) ', ( ) => {
describe ( ' urlsafeSlugProcessor ', ( ) => {
describe ( 'ascii' , ( ) => {
describe ( 'ascii' , ( ) => {
it ( 'space separated words' , ( ) => {
it ( 'space separated words' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Text expressions' ) ,
urlsafeSlug Processor( 'Text expressions' ) ,
` t ext${ _ } expressions `
` T ext${ _ } expressions `
) ;
) ;
} ) ;
} ) ;
it ( 'numbered text' , ( ) => {
it ( 'numbered text' , ( ) => {
assert . equal (
assert . equal (
limax Processor( '1. export creates' ) ,
urlsafeSlug Processor( '1. export creates' ) ,
` 1 ${ _ } export ${ _ } creates `
` 1 ${ _ } export ${ _ } creates `
) ;
) ;
} ) ;
} ) ;
it ( 'punctuated text' , ( ) => {
it ( 'punctuated text' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'svelte.VERSION' ) ,
urlsafeSlug Processor( 'svelte.VERSION' ) ,
` svelte ${ _ } version `
` svelte ${ _ } VERSION `
) ;
) ;
} ) ;
} ) ;
it ( 'text starting with the dollar sign' , ( ) => {
it ( 'text starting with the dollar sign' , ( ) => {
assert . equal (
assert . equal (
limax Processor( '$destroy method' ) ,
urlsafeSlug Processor( '$destroy method' ) ,
` $ destroy ${ _ } method `
` $ destroy ${ _ } method `
) ;
) ;
} ) ;
} ) ;
it ( 'numbered text containing the dollar sign' , ( ) => {
it ( 'numbered text containing the dollar sign' , ( ) => {
assert . equal (
assert . equal (
limax Processor( '1. export $destroy' ) ,
urlsafeSlug Processor( '1. export $destroy' ) ,
` 1 ${ _ } export ${ _ } $ destroy `
` 1 ${ _ } export ${ _ } $ destroy `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the equal char' , ( ) => {
it ( 'text containing the equal char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'script context=module' ) ,
urlsafeSlug Processor( 'script context=module' ) ,
` script ${ _ } context ${ _ } module `
` script ${ _ } context ${ _ } module `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the colon char' , ( ) => {
it ( 'text containing the colon char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'svelte:body' ) ,
urlsafeSlug Processor( 'svelte:body' ) ,
` svelte ${ _ } body `
` svelte ${ _ } body `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the slash char' , ( ) => {
it ( 'text containing the slash char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'svelte/motion' ) ,
urlsafeSlug Processor( 'svelte/motion' ) ,
` svelte ${ _ } motion `
` svelte ${ _ } motion `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the comma char' , ( ) => {
it ( 'text containing the comma char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'svelte, motion' ) ,
urlsafeSlug Processor( 'svelte, motion' ) ,
` svelte ${ _ } motion `
` svelte ${ _ } motion `
) ;
) ;
} ) ;
} ) ;
@ -63,156 +63,150 @@ describe('slug', () => {
describe ( 'unicode' , ( ) => {
describe ( 'unicode' , ( ) => {
it ( 'should translate symbols to English' , ( ) => {
it ( 'should translate symbols to English' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Ich ♥ Deutsch' ) ,
urlsafeSlug Processor( 'Ich ♥ Deutsch' ) ,
` ich${ _ } love ${ _ } d eutsch`
` Ich${ _ } love ${ _ } D eutsch`
) ;
) ;
} ) ;
} ) ;
it ( 'should remove emoji' , ( ) => {
it ( 'should remove emoji' , ( ) => {
assert . equal (
assert . equal (
limaxProcessor ( 'Ich 😍 Deutsch' ) ,
urlsafeSlugProcessor ( 'Ich 😍 Deutsch' ) ,
` ich ${ _ } deutsch `
` Ich ${ _ } Deutsch `
) ;
} ) ;
it ( 'should translate symbols to the given language (German)' , ( ) => {
assert . equal (
limaxProcessor ( 'Ich ♥ Deutsch' , 'de' ) ,
` ich ${ _ } liebe ${ _ } deutsch `
) ;
) ;
} ) ;
} ) ;
} ) ;
} ) ;
describe ( 'cyricllic' , ( ) => {
describe ( 'cyricllic' , ( ) => {
it ( 'space separated words' , ( ) => {
it ( 'space separated words' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Всплытие и перехват событий' ) ,
urlsafeSlug Processor( 'Всплытие и перехват событий' ) ,
` vsplytie${ _ } i ${ _ } perekhvat ${ _ } sobytii `
` Vsplytie${ _ } i ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'numbered text' , ( ) => {
it ( 'numbered text' , ( ) => {
assert . equal (
assert . equal (
limax Processor( '1 Всплытие и перехват событий' ) ,
urlsafeSlug Processor( '1 Всплытие и перехват событий' ) ,
` 1 ${ _ } vsplytie${ _ } i ${ _ } perekhvat ${ _ } sobytii `
` 1 ${ _ } Vsplytie${ _ } i ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'punctuated text' , ( ) => {
it ( 'punctuated text' , ( ) => {
assert . equal (
assert . equal (
limax Processor( '.Всплытие.и.перехват событий' ) ,
urlsafeSlug Processor( '.Всплытие.и.перехват событий' ) ,
` vsplytie${ _ } i ${ _ } perekhvat ${ _ } sobytii `
` Vsplytie${ _ } i ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text starting with the dollar sign' , ( ) => {
it ( 'text starting with the dollar sign' , ( ) => {
assert . equal (
assert . equal (
limax Processor( '$Всплытие $ перехват событий' ) ,
urlsafeSlug Processor( '$Всплытие $ перехват событий' ) ,
` $ vsplytie${ _ } $ ${ _ } perekhvat ${ _ } sobytii `
` $ Vsplytie${ _ } $ ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the dollar sign' , ( ) => {
it ( 'text containing the dollar sign' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Всплытие$перехват' ) ,
urlsafeSlug Processor( 'Всплытие$перехват' ) ,
` vsplytie$ perek hvat`
` Vsplytie$ pere hvat`
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the equal char' , ( ) => {
it ( 'text containing the equal char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Всплытие = перехват=событий' ) ,
urlsafeSlug Processor( 'Всплытие = перехват=событий' ) ,
` vsplytie${ _ } perekhvat ${ _ } sobytii `
` Vsplytie${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the colon char' , ( ) => {
it ( 'text containing the colon char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Всплытие : перехват:событий' ) ,
urlsafeSlug Processor( 'Всплытие : перехват:событий' ) ,
` vsplytie${ _ } perekhvat ${ _ } sobytii `
` Vsplytie${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the slash char' , ( ) => {
it ( 'text containing the slash char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Всплытие / перехват/событий' ) ,
urlsafeSlug Processor( 'Всплытие / перехват/событий' ) ,
` vsplytie${ _ } perekhvat ${ _ } sobytii `
` Vsplytie${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the comma char' , ( ) => {
it ( 'text containing the comma char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Всплытие, перехват' ) ,
urlsafeSlug Processor( 'Всплытие, перехват' ) ,
` vsplytie${ _ } perek hvat`
` Vsplytie${ _ } pere hvat`
) ;
) ;
} ) ;
} ) ;
} ) ;
} ) ;
describe ( 'ascii + cyricllic' , ( ) => {
describe ( 'ascii + cyricllic' , ( ) => {
it ( 'space separated words' , ( ) => {
it ( 'space separated words' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Всплытие и export перехват событий' ) ,
urlsafeSlug Processor( 'Всплытие и export перехват событий' ) ,
` v splytie${ _ } i ${ _ } export ${ _ } pere khvat${ _ } sobytii `
` V splytie${ _ } i ${ _ } export ${ _ } pere hvat${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'ascii word concatenated to a cyricllic word' , ( ) => {
it ( 'ascii word concatenated to a cyricllic word' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'exportВ с плытие ' ) ,
urlsafeSlug Processor( 'exportВ с плытие ' ) ,
'export v splytie'
'export V splytie'
) ;
) ;
} ) ;
} ) ;
it ( 'cyricllic word concatenated to an ascii word' , ( ) => {
it ( 'cyricllic word concatenated to an ascii word' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'В с плытие export' ) ,
urlsafeSlug Processor( 'В с плытие export' ) ,
` v splytieexport`
` V splytieexport`
) ;
) ;
} ) ;
} ) ;
it ( 'numbered text' , ( ) => {
it ( 'numbered text' , ( ) => {
assert . equal (
assert . equal (
limax Processor( '1 export Всплытие и перехват событий' ) ,
urlsafeSlug Processor( '1 export Всплытие и перехват событий' ) ,
` 1 ${ _ } export ${ _ } vsplytie${ _ } i ${ _ } perekhvat ${ _ } sobytii `
` 1 ${ _ } export ${ _ } Vsplytie${ _ } i ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'punctuated text' , ( ) => {
it ( 'punctuated text' , ( ) => {
assert . equal (
assert . equal (
limax Processor( '.Всплытие.export.и.перехват событий' ) ,
urlsafeSlug Processor( '.Всплытие.export.и.перехват событий' ) ,
` v splytie${ _ } export ${ _ } i ${ _ } pere khvat${ _ } sobytii `
` V splytie${ _ } export ${ _ } i ${ _ } pere hvat${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text starting with the dollar sign, followed by ascii char' , ( ) => {
it ( 'text starting with the dollar sign, followed by ascii char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( '$exportВ с плытие перехват событий' ) ,
urlsafeSlug Processor( '$exportВ с плытие перехват событий' ) ,
` $ export vsplytie${ _ } perekhvat ${ _ } sobytii `
` $ export Vsplytie${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text starting with the dollar sign, followed by unicode char' , ( ) => {
it ( 'text starting with the dollar sign, followed by unicode char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( '$Всплытие export перехват событий' ) ,
urlsafeSlug Processor( '$Всплытие export перехват событий' ) ,
` $ vsplytie${ _ } export ${ _ } perekhvat ${ _ } sobytii `
` $ Vsplytie${ _ } export ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the dollar sign, followed by ascii char' , ( ) => {
it ( 'text containing the dollar sign, followed by ascii char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'export $destroy a component prop Всплытие и перехват событий' ) ,
urlsafeSlug Processor( 'export $destroy a component prop Всплытие и перехват событий' ) ,
` export ${ _ } $ destroy ${ _ } a ${ _ } component ${ _ } prop ${ _ } vsplytie${ _ } i ${ _ } perekhvat ${ _ } sobytii `
` export ${ _ } $ destroy ${ _ } a ${ _ } component ${ _ } prop ${ _ } Vsplytie${ _ } i ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the dollar sign, followed by unicode char' , ( ) => {
it ( 'text containing the dollar sign, followed by unicode char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Всплытие export $Всплытие a component prop Всплытие и перехват событий' ) ,
urlsafeSlug Processor( 'Всплытие export $Всплытие a component prop Всплытие и перехват событий' ) ,
` vsplytie${ _ } export ${ _ } $ v splytie${ _ } a ${ _ } component ${ _ } prop ${ _ } vsplytie${ _ } i ${ _ } perekhvat ${ _ } sobytii `
` Vsplytie${ _ } export ${ _ } $ V splytie${ _ } a ${ _ } component ${ _ } prop ${ _ } Vsplytie${ _ } i ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the equal char' , ( ) => {
it ( 'text containing the equal char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'script context=module Всплытие=и перехват событий' ) ,
urlsafeSlug Processor( 'script context=module Всплытие=и перехват событий' ) ,
` script ${ _ } context ${ _ } module ${ _ } vsplytie${ _ } i ${ _ } perekhvat ${ _ } sobytii `
` script ${ _ } context ${ _ } module ${ _ } Vsplytie${ _ } i ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the colon char' , ( ) => {
it ( 'text containing the colon char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'svelte:body Всплытие и:перехват событий' ) ,
urlsafeSlug Processor( 'svelte:body Всплытие и:перехват событий' ) ,
` svelte ${ _ } body ${ _ } vsplytie${ _ } i ${ _ } perekhvat ${ _ } sobytii `
` svelte ${ _ } body ${ _ } Vsplytie${ _ } i ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the slash char' , ( ) => {
it ( 'text containing the slash char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'svelte/motion Всплытие и / перехват/событий' ) ,
urlsafeSlug Processor( 'svelte/motion Всплытие и / перехват/событий' ) ,
` svelte ${ _ } motion ${ _ } vsplytie${ _ } i ${ _ } perekhvat ${ _ } sobytii `
` svelte ${ _ } motion ${ _ } Vsplytie${ _ } i ${ _ } perehvat ${ _ } sobytij `
) ;
) ;
} ) ;
} ) ;
it ( 'text containing the comma char' , ( ) => {
it ( 'text containing the comma char' , ( ) => {
assert . equal (
assert . equal (
limax Processor( 'Всплытие, export' ) ,
urlsafeSlug Processor( 'Всплытие, export' ) ,
` v splytie${ _ } export `
` V splytie${ _ } export `
) ;
) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -223,7 +217,7 @@ describe('slug', () => {
it ( 'space separated words' , ( ) => {
it ( 'space separated words' , ( ) => {
assert . equal (
assert . equal (
unicodeSafeProcessor ( 'Text expressions' ) ,
unicodeSafeProcessor ( 'Text expressions' ) ,
` t ext${ _ } expressions `
` T ext${ _ } expressions `
) ;
) ;
} ) ;
} ) ;
it ( 'numbered text' , ( ) => {
it ( 'numbered text' , ( ) => {
@ -235,7 +229,7 @@ describe('slug', () => {
it ( 'punctuated text' , ( ) => {
it ( 'punctuated text' , ( ) => {
assert . equal (
assert . equal (
unicodeSafeProcessor ( 'svelte.VERSION' ) ,
unicodeSafeProcessor ( 'svelte.VERSION' ) ,
` svelte ${ _ } version `
` svelte ${ _ } VERSION `
) ;
) ;
} ) ;
} ) ;
it ( 'text starting with the dollar sign' , ( ) => {
it ( 'text starting with the dollar sign' , ( ) => {
@ -279,13 +273,13 @@ describe('slug', () => {
it ( 'should preserve symbols' , ( ) => {
it ( 'should preserve symbols' , ( ) => {
assert . equal (
assert . equal (
unicodeSafeProcessor ( 'Ich ♥ Deutsch' ) ,
unicodeSafeProcessor ( 'Ich ♥ Deutsch' ) ,
` ich${ _ } love ${ _ } d eutsch`
` Ich${ _ } love ${ _ } D eutsch`
) ;
) ;
} ) ;
} ) ;
it ( 'should remove emoji' , ( ) => {
it ( 'should remove emoji' , ( ) => {
assert . equal (
assert . equal (
unicodeSafeProcessor ( 'Ich 😍 Deutsch' ) ,
unicodeSafeProcessor ( 'Ich 😍 Deutsch' ) ,
` ich${ _ } d eutsch`
` Ich${ _ } D eutsch`
) ;
) ;
} ) ;
} ) ;
} ) ;
} ) ;