File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,19 @@ export const removeFirstSharp = (id_str) => {
13
13
} ;
14
14
15
15
export const removeLastSlash = ( url ) => {
16
+ if ( ! isValidVariable ( url ) ) {
17
+ return null ;
18
+ }
16
19
if ( url . length > 1 && / \/ $ / . test ( url ) ) {
17
20
url = url . slice ( 0 , - 1 ) ;
18
21
}
19
22
return url ;
20
23
} ;
21
24
22
25
export const removeLastSpace = ( url ) => {
26
+ if ( ! isValidVariable ( url ) ) {
27
+ return null ;
28
+ }
23
29
if ( url . length > 1 && / + $ / . test ( url ) ) {
24
30
url = url . slice ( 0 , - 1 ) ;
25
31
}
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ describe('removeFirstSharp', () => {
24
24
test ( '#1234' , ( ) => {
25
25
expect ( removeFirstSharp ( '#1234' ) ) . toBe ( '1234' ) ;
26
26
} ) ;
27
+
28
+ test ( 'null' , ( ) => {
29
+ expect ( removeFirstSharp ( null ) ) . toBe ( null ) ;
30
+ } ) ;
27
31
} ) ;
28
32
29
33
describe ( 'removeLastSlash' , ( ) => {
@@ -34,6 +38,10 @@ describe('removeLastSlash', () => {
34
38
test ( 'a/a' , ( ) => {
35
39
expect ( removeLastSlash ( 'a/a' ) ) . toBe ( 'a/a' ) ;
36
40
} ) ;
41
+
42
+ test ( 'null' , ( ) => {
43
+ expect ( removeLastSlash ( null ) ) . toBe ( null ) ;
44
+ } ) ;
37
45
} ) ;
38
46
39
47
describe ( 'removeLastSpace' , ( ) => {
@@ -44,6 +52,10 @@ describe('removeLastSpace', () => {
44
52
test ( 'a a' , ( ) => {
45
53
expect ( removeLastSpace ( 'a a' ) ) . toBe ( 'a a' ) ;
46
54
} ) ;
55
+
56
+ test ( 'null' , ( ) => {
57
+ expect ( removeLastSpace ( null ) ) . toBe ( null ) ;
58
+ } ) ;
47
59
} ) ;
48
60
49
61
const failed_yaml_description_part = `\`\`\`yaml
You can’t perform that action at this time.
0 commit comments