Skip to content

Commit 67a6d2c

Browse files
committed
fix(core): adjust loader to bail on only falsy url when multiple urls are passed in
1 parent c83d80b commit 67a6d2c

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

libs/core/src/lib/loader.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,18 @@ const cached = new Map();
3434
const memoizedLoaders = new WeakMap();
3535

3636
function normalizeInputs(input: string | string[] | Record<string, string>) {
37-
if (Array.isArray(input)) return input;
38-
if (typeof input === 'string') return [input];
39-
return Object.values(input);
37+
let urls: string[] = [];
38+
if (Array.isArray(input)) {
39+
urls = input;
40+
} else if (typeof input === 'string') {
41+
urls = [input];
42+
} else {
43+
urls = Object.values(input);
44+
}
45+
46+
return urls.map((url) => {
47+
return url.includes('undefined') || url.includes('null') || !url ? '' : url;
48+
});
4049
}
4150

4251
function load<
@@ -60,8 +69,6 @@ function load<
6069
return (): Array<Promise<any>> | null => {
6170
const urls = normalizeInputs(inputs());
6271

63-
if (urls.some((url) => url.includes('undefined'))) return null;
64-
6572
let loader: Loader<TData> = memoizedLoaders.get(loaderConstructorFactory(urls));
6673
if (!loader) {
6774
loader = new (loaderConstructorFactory(urls))();
@@ -71,6 +78,10 @@ function load<
7178
if (extensions) extensions(loader);
7279
// TODO: reevaluate this
7380
return urls.map((url) => {
81+
if (url === '') {
82+
return null;
83+
}
84+
7485
if (!cached.has(url)) {
7586
cached.set(
7687
url,

0 commit comments

Comments
 (0)