@@ -19,7 +19,7 @@ const siteGitBookIO = createLinker({
19
19
siteBasePath : '/sitename/' ,
20
20
} ) ;
21
21
22
- describe ( 'toPathInContent ' , ( ) => {
22
+ describe ( 'toPathInSpace ' , ( ) => {
23
23
it ( 'should return the correct path' , ( ) => {
24
24
expect ( root . toPathInSpace ( 'some/path' ) ) . toBe ( '/some/path' ) ;
25
25
expect ( variantInSection . toPathInSpace ( 'some/path' ) ) . toBe ( '/section/variant/some/path' ) ;
@@ -29,13 +29,33 @@ describe('toPathInContent', () => {
29
29
expect ( root . toPathInSpace ( '/some/path' ) ) . toBe ( '/some/path' ) ;
30
30
expect ( variantInSection . toPathInSpace ( '/some/path' ) ) . toBe ( '/section/variant/some/path' ) ;
31
31
} ) ;
32
+
33
+ it ( 'should remove the trailing slash' , ( ) => {
34
+ expect ( root . toPathInSpace ( 'some/path/' ) ) . toBe ( '/some/path' ) ;
35
+ expect ( variantInSection . toPathInSpace ( 'some/path/' ) ) . toBe ( '/section/variant/some/path' ) ;
36
+ } ) ;
37
+
38
+ it ( 'should not add a trailing slash' , ( ) => {
39
+ expect ( root . toPathInSpace ( '' ) ) . toBe ( '' ) ;
40
+ expect ( variantInSection . toPathInSpace ( '' ) ) . toBe ( '/section/variant' ) ;
41
+ } ) ;
32
42
} ) ;
33
43
34
44
describe ( 'toPathInSite' , ( ) => {
35
45
it ( 'should return the correct path' , ( ) => {
36
46
expect ( root . toPathInSite ( 'some/path' ) ) . toBe ( '/some/path' ) ;
37
47
expect ( siteGitBookIO . toPathInSite ( 'some/path' ) ) . toBe ( '/sitename/some/path' ) ;
38
48
} ) ;
49
+
50
+ it ( 'should remove the trailing slash' , ( ) => {
51
+ expect ( root . toPathInSite ( 'some/path/' ) ) . toBe ( '/some/path' ) ;
52
+ expect ( siteGitBookIO . toPathInSite ( 'some/path/' ) ) . toBe ( '/sitename/some/path' ) ;
53
+ } ) ;
54
+
55
+ it ( 'should not add a trailing slash' , ( ) => {
56
+ expect ( root . toPathInSite ( '' ) ) . toBe ( '' ) ;
57
+ expect ( siteGitBookIO . toPathInSite ( '' ) ) . toBe ( '/sitename' ) ;
58
+ } ) ;
39
59
} ) ;
40
60
41
61
describe ( 'toRelativePathInSite' , ( ) => {
0 commit comments