Skip to content

Commit

Permalink
refactor: minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
aorumbayev committed Dec 7, 2023
1 parent 7c5a1ed commit 75bed49
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
18 changes: 1 addition & 17 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,6 @@ export class ByteArrayMap<T> {
}
}

export function filePathRelativeTo(base: string, filePath: string): string {
// Normalize the base path to convert any Windows backslashes to forward slashes
// This is necessary because the URL object expects forward slashes
const normalizedBase = base.replace(/\\/g, '/');

// Create a URL object with the file protocol and the normalized base path
const baseURL = new URL(normalizedBase, 'file:///');

// Resolve the file path against the base URL
const fullURL = new URL(filePath, baseURL);

// Convert the URL back to a local file path
// On Windows, this will correctly handle the drive letter and convert to backslashes
return fullURL.pathname;
}

interface ProgramSourceEntryFile {
'txn-group-sources': ProgramSourceEntry[];
}
Expand Down Expand Up @@ -187,7 +171,7 @@ export class ProgramSourceDescriptor {
originFile: string,
data: ProgramSourceEntry,
): Promise<ProgramSourceDescriptor> {
const sourcemapFileLocation = filePathRelativeTo(
const sourcemapFileLocation = fileAccessor.filePathRelativeTo(
originFile,
data['sourcemap-location'],
);
Expand Down
31 changes: 0 additions & 31 deletions tests/common/utils.test.ts

This file was deleted.

0 comments on commit 75bed49

Please sign in to comment.