Skip to content

Commit 0cfd245

Browse files
authored
Use pathToFileURL for dynamic import of config file (#3233)
* Use `pathToFileURL(configFilePath).href` when importing the config to ensure cross-platform compatibility (Windows _(windows filepath)_, macOS _(posix)_, Linux _(posix)_) and correct handling of special characters. The `windows` option is left `undefined`, so the platform system default is used. * See docs here: https://nodejs.org/api/url.html#urlpathtofileurlpath-options
1 parent a09c792 commit 0cfd245

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

QualityControl/lib/config/configProvider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import { LogManager } from '@aliceo2/web-ui';
1717
import { realpath } from 'node:fs/promises';
1818
import { dirname, join } from 'path';
19-
import { fileURLToPath } from 'url';
19+
import { fileURLToPath, pathToFileURL } from 'url';
2020

2121
const logger = LogManager.getLogger(`${process.env.npm_config_log_label ?? 'qcg'}/config`);
2222

@@ -27,7 +27,7 @@ let configFilePath = _getConfigurationFilePath();
2727

2828
try {
2929
configFilePath = await realpath(configFilePath);
30-
({ config } = await import(configFilePath));
30+
({ config } = await import(pathToFileURL(configFilePath).href));
3131

3232
logger.info(`Configuration file successfully read from: "${configFilePath}"`);
3333
} catch (err) {

0 commit comments

Comments
 (0)