Skip to content

Commit 81f63c2

Browse files
Copiloticlanton
andcommitted
Address code review feedback: improve regex pattern and add JSDoc return description
Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
1 parent f9e7b87 commit 81f63c2

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

libraries/rush-lib/src/utilities/npmrcUtilities.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const NPM_INCOMPATIBLE_PROPERTIES: Set<string> = new Set([
9696
* @param env The environment variables object
9797
* @param supportEnvVarFallbackSyntax Whether to support fallback values in the form of `${VAR_NAME:-fallback}`
9898
* @param filterNpmIncompatibleProperties Whether to filter out properties that npm doesn't understand
99-
* @returns
99+
* @returns An array of processed npmrc file lines with undefined environment variables and npm-incompatible properties commented out
100100
*/
101101
export function trimNpmrcFileLines(
102102
npmrcFileLines: string[],
@@ -127,14 +127,14 @@ export function trimNpmrcFileLines(
127127
// Check if this is a property that npm doesn't understand
128128
if (filterNpmIncompatibleProperties) {
129129
// Extract the property name (everything before the '=' or '[')
130-
const match: RegExpMatchArray | null = line.match(/^([^=\[]+)/);
130+
const match: RegExpMatchArray | null = line.match(/^([^=\[\s]+)/);
131131
if (match) {
132-
const propertyName: string = match[1].trim();
133-
132+
const propertyName: string = match[1];
133+
134134
// Never filter registry-scoped properties (auth tokens, etc.)
135135
// These start with "//" like "//registry.npmjs.org/:_authToken"
136136
const isRegistryScoped: boolean = propertyName.startsWith('//');
137-
137+
138138
if (!isRegistryScoped && NPM_INCOMPATIBLE_PROPERTIES.has(propertyName)) {
139139
lineShouldBeTrimmed = true;
140140
}

0 commit comments

Comments
 (0)