Skip to content

Commit b1068f3

Browse files
fix: Apply CR suggestions
- Update isDefinitionUrlValid(). - Avoid object destructuring. Co-authored-by: Chris Eppstein <[email protected]>
1 parent e757f4d commit b1068f3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

packages/@css-blocks/core/src/PrecompiledDefinitions/compiled-comments.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ export const REGEXP_COMMENT_FOOTER = /\/\*#css-blocks end\*\//m;
3131
* @returns True if valid given the above rules, false otherwise.
3232
*/
3333
export function isDefinitionUrlValid(urlOrPath: string): boolean {
34-
// Try to parse as a URL first.
34+
if (path.isAbsolute(urlOrPath)) {
35+
return false;
36+
}
3537
const parsedUrl = url.parse(urlOrPath);
3638
if (parsedUrl.protocol) {
3739
return parsedUrl.protocol === "data:";
40+
} else {
41+
return true;
3842
}
39-
40-
// If we can't parse as a URL with a protocol, it's a path.
41-
return !path.isAbsolute(urlOrPath);
4243
}

packages/@css-blocks/core/src/importing/BaseImporter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ export abstract class BaseImporter implements Importer {
7474

7575
// Determine start/end indexes based on the regexp results above.
7676
const [headerFullMatch, blockIdFromComment] = headerRegexpResult;
77-
const { index: headerStartIndex } = headerRegexpResult;
77+
const headerStartIndex = headerRegexpResult.index;
7878
if (!headerStartIndex) {
7979
throw new Error("Unable to determine start location of regexp result.");
8080
}
8181
const headerEndIndex = headerStartIndex + headerFullMatch.length;
8282
const [footerFullMatch] = footerRegexpResult;
83-
const { index: footerStartIndex } = footerRegexpResult;
83+
const footerStartIndex = footerRegexpResult.index;
8484
if (!footerStartIndex) {
8585
throw new Error("Unable to determine start location of regexp result.");
8686
}

0 commit comments

Comments
 (0)