Skip to content

Commit 70a2c26

Browse files
committed
bugfix
1 parent ba492d0 commit 70a2c26

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/functions/Common/Parser.js

+6
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ export const removeFirstSharp = (id_str) => {
1313
};
1414

1515
export const removeLastSlash = (url) => {
16+
if(!isValidVariable(url)){
17+
return null;
18+
}
1619
if (url.length > 1 && /\/$/.test(url)) {
1720
url = url.slice(0, -1);
1821
}
1922
return url;
2023
};
2124

2225
export const removeLastSpace = (url) => {
26+
if(!isValidVariable(url)){
27+
return null;
28+
}
2329
if (url.length > 1 && / +$/.test(url)) {
2430
url = url.slice(0, -1);
2531
}

src/functions/Common/Parser.test.js

+12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ describe('removeFirstSharp', () => {
2424
test('#1234', () => {
2525
expect(removeFirstSharp('#1234')).toBe('1234');
2626
});
27+
28+
test('null', () => {
29+
expect(removeFirstSharp(null)).toBe(null);
30+
});
2731
});
2832

2933
describe('removeLastSlash', () => {
@@ -34,6 +38,10 @@ describe('removeLastSlash', () => {
3438
test('a/a', () => {
3539
expect(removeLastSlash('a/a')).toBe('a/a');
3640
});
41+
42+
test('null', () => {
43+
expect(removeLastSlash(null)).toBe(null);
44+
});
3745
});
3846

3947
describe('removeLastSpace', () => {
@@ -44,6 +52,10 @@ describe('removeLastSpace', () => {
4452
test('a a', () => {
4553
expect(removeLastSpace('a a')).toBe('a a');
4654
});
55+
56+
test('null', () => {
57+
expect(removeLastSpace(null)).toBe(null);
58+
});
4759
});
4860

4961
const failed_yaml_description_part = `\`\`\`yaml

0 commit comments

Comments
 (0)