Fixed parseUrl to output catalogPaths beginning with '/'

This commit is contained in:
Nir Gazit
2021-02-09 20:32:15 +02:00
parent 6174617405
commit d444fee636
2 changed files with 4 additions and 4 deletions
@@ -33,14 +33,14 @@ describe('GithubDiscoveryProcessor', () => {
).toEqual({
org: 'foo',
repoSearchPath: /^proj$/,
catalogPath: 'blob/master/catalog.yaml',
catalogPath: '/blob/master/catalog.yaml',
});
expect(
parseUrl('https://github.com/foo/proj*/blob/master/catalog.yaml'),
).toEqual({
org: 'foo',
repoSearchPath: /^proj.*$/,
catalogPath: 'blob/master/catalog.yaml',
catalogPath: '/blob/master/catalog.yaml',
});
});
@@ -92,7 +92,7 @@ export class GithubDiscoveryProcessor implements CatalogProcessor {
results.location(
{
type: 'url',
target: `${repository.url}/${catalogPath}`,
target: `${repository.url}${catalogPath}`,
},
false,
),
@@ -118,7 +118,7 @@ export function parseUrl(
return {
org: decodeURIComponent(path[0]),
repoSearchPath: escapeRegExp(decodeURIComponent(path[1])),
catalogPath: decodeURIComponent(path.slice(2).join('/')),
catalogPath: `/${decodeURIComponent(path.slice(2).join('/'))}`,
};
}