Skip to content

Commit

Permalink
implement bug fix for paths (#7)
Browse files Browse the repository at this point in the history
sometimes path may be a CDN url
  • Loading branch information
hwrdtm authored Mar 5, 2021
1 parent b208fc7 commit 0b0ede6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export const createValidUri = (host: string, path: string): string => {
return path;
}

if (path.startsWith('http') || path.startsWith('https')) {
return path;
}

const updatedPath = path.replace('/', '');
return `${host}${updatedPath}`;
};
5 changes: 5 additions & 0 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ test('returns the path', t => {
const result: string = createValidUri('https://github.com/', 'https://github.com/rocktimsaikia');
t.is(result, 'https://github.com/rocktimsaikia');
});

test('returns CDN paths', t => {
const result: string = createValidUri('https://medium.com/', 'https://cdn-static-1.medium.com/_/fp/icons/Medium-Avatar-500x500.svg');
t.is(result, 'https://cdn-static-1.medium.com/_/fp/icons/Medium-Avatar-500x500.svg');
});

0 comments on commit 0b0ede6

Please sign in to comment.