Skip to content

Commit 4ce8302

Browse files
committed
style: refactor parseUriParts function for improved readability by merging nested ifs
1 parent 1bdcf26 commit 4ce8302

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/templateCompilerModules/utils.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,10 @@ export function urlToRequire(
6262
function parseUriParts(urlString: string): UrlWithStringQuery {
6363
// initialize return value
6464
const returnValue: UrlWithStringQuery = uriParse('')
65-
if (urlString) {
66-
// A TypeError is thrown if urlString is not a string
67-
// @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
68-
if ('string' === typeof urlString) {
69-
// check is an uri
70-
return uriParse(urlString) // take apart the uri
71-
}
65+
// A TypeError is thrown if urlString is not a string
66+
// @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
67+
if (urlString && 'string' === typeof urlString) {
68+
return uriParse(urlString) // take apart the uri
7269
}
7370
return returnValue
7471
}

0 commit comments

Comments
 (0)