Skip to content

Commit

Permalink
Fix case sensitivity in package name check (resolves #869)
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Dec 3, 2024
1 parent 35d38a2 commit d6dab3d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/knip/fixtures/dependencies/my-module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import has from 'has';
import JSONStream from 'JSONStream';

JSONStream;

async function main() {
return [require('ansi-regex'), import('ansi-regex')];
Expand Down
3 changes: 2 additions & 1 deletion packages/knip/fixtures/dependencies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"@sindresorhus/is": "*",
"fs-extra": "*",
"has": "*",
"stream": "*"
"stream": "*",
"JSONStream": "*"
},
"peerDependencies": {
"ansi-regex": "*",
Expand Down
2 changes: 1 addition & 1 deletion packages/knip/src/util/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const getPackageNameFromFilePath = (value: string) => {
export const getPackageNameFromSpecifier = (specifier: string) =>
isInNodeModules(specifier) ? getPackageNameFromFilePath(specifier) : getPackageNameFromModuleSpecifier(specifier);

export const isStartsLikePackageName = (specifier: string) => /^(@[a-z0-9._]|[a-z0-9])/.test(specifier);
export const isStartsLikePackageName = (specifier: string) => /^(@[a-z0-9._]|[a-z0-9])/i.test(specifier);

This comment has been minimized.

Copy link
@boneskull

boneskull Dec 3, 2024

well, coulda fixed that myself I suppose 😆

This comment has been minimized.

Copy link
@webpro

webpro Dec 4, 2024

Author Collaborator

Sometimes the $100K fix is a single yet well-placed character..


export const stripVersionFromSpecifier = (specifier: string) => specifier.replace(/(\S+)@.*/, '$1');

Expand Down

0 comments on commit d6dab3d

Please sign in to comment.