Skip to content

Commit

Permalink
Fix compatibility with older Node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jathak committed Oct 15, 2024
1 parent e64025b commit ca318b0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/src/legacy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {pathToFileURL} from 'url';
import {fileUrlToPathCrossPlatform} from '../utils';
import {SourceSpan} from '../vendor/sass';
import {legacyImporterFileProtocol} from './importer';
import { remove } from 'immutable';

Check failure on line 11 in lib/src/legacy/utils.ts

View workflow job for this annotation

GitHub Actions / Static analysis

Replace `·remove·` with `remove`

Check warning on line 11 in lib/src/legacy/utils.ts

View workflow job for this annotation

GitHub Actions / Static analysis

'remove' is defined but never used

/**
* The URL protocol to use for URLs canonicalized using `LegacyImporterWrapper`.
Expand Down Expand Up @@ -39,12 +40,12 @@ export function removeLegacyImporter(string: string): string {
export function removeLegacyImporterFromSpan(span: SourceSpan): SourceSpan {
if (!span.url) return span;
const url = removeLegacyImporter(span.url.toString());
return {
...span,
url: URL.canParse(url)
? new URL(url)
: new URL(url, `file://${process.cwd()}/`),
};
try {
return {...span, url: new URL(url)};
} catch (_) {
// Relative URL
return {...span, url: new URL(url, `file://${process.cwd()}`)};
}
}

// Converts [path] to a `file:` URL and adds the [legacyImporterProtocolPrefix]
Expand Down

0 comments on commit ca318b0

Please sign in to comment.