use absolute urls

Signed-off-by: Kiss Miklos <miklos@roadie.io>
This commit is contained in:
Kiss Miklos
2022-07-05 15:23:27 +02:00
parent e75bde1342
commit 7c85fa3aa3
4 changed files with 16 additions and 5 deletions
@@ -89,7 +89,7 @@ describe('FileReaderProcessor', () => {
type: 'file',
target: expect.stringMatching(/^[^*]*$/),
});
expect(emit.mock.calls[1][0].key).toContain('file:');
expect(emit.mock.calls[1][0].key).toContain('file://');
expect(emit.mock.calls[1][0].key).toContain(
'fileReaderProcessor/component.yaml',
);
@@ -52,6 +52,7 @@ export class FileReaderProcessor implements CatalogProcessor {
if (fileMatches.length > 0) {
for (const fileMatch of fileMatches) {
const data = await fs.readFile(fileMatch);
const normalizedFilePath = path.normalize(fileMatch);
// The normalize converts to native slashes; the glob library returns
// forward slashes even on windows
@@ -59,13 +60,13 @@ export class FileReaderProcessor implements CatalogProcessor {
data: data,
location: {
type: LOCATION_TYPE,
target: path.normalize(fileMatch),
target: normalizedFilePath,
},
})) {
emit(parseResult);
emit(
processingResult.refresh(
`${LOCATION_TYPE}:${path.normalize(fileMatch)}`,
`${LOCATION_TYPE}://${normalizedFilePath}`,
),
);
}
@@ -385,7 +385,7 @@ describe('PlaceholderProcessor', () => {
console.log(emitted);
expect(emitted[0]).toEqual({
type: 'refresh',
key: 'url:./path-to-file.json',
key: 'url:http://example.com/path-to-file.json',
});
});
});
@@ -134,7 +134,17 @@ export class PlaceholderProcessor implements CatalogProcessor {
base,
});
emit(processingResult.refresh(`url:${resolverValue}`));
emit(
processingResult.refresh(
`url:${relativeUrl({
key: resolverKey,
value: resolverValue,
baseUrl: location.target,
read,
resolveUrl,
})}`,
),
);
return [
await resolver({