scancode.io icon indicating copy to clipboard operation
scancode.io copied to clipboard

Improving D2D mapping for npm - Basename matching

Open chinyeungli opened this issue 1 year ago • 1 comments

In some cases, file extensions may differ between the deployment codebase and the development codebase due to transformations during the build process. The tool should account for these discrepancies and perform mapping based on file basenames where appropriate. Below is the proposed list of basename matches to support this logic:

deployed extension can be from extension notes
.cjs .ts, .mts or .js
.mjs .ts, .mts or .js
.css .less or .scss
.d.ts .ts or .js
.js .ts
.min.js .js
.js .ts, .tsx, .coffee, .jsx, .vue. .svelte, .elm
.bak It is a backup typed file
"extension1"."extension2" "extension1" nrlmsise_interface.cpp.o <- nrlmsise_interface.cpp
headers.h.gch <- headers.h
.d.mts .mts, .ts
"filename" "filename" In certain cases, files may share the same filename but differ in their hash values due to changes during the build process. To determine a valid match, the tool should consider both the filename and the corresponding path.

chinyeungli avatar Sep 11 '25 10:09 chinyeungli

hey @chinyeungli , I have fixed the problem and tested the solution.

I enhanced get_basename_without_extension() and extended the logic in find_basename_matches() to correctly link deployed files back to their original sources, and added a dictionary-based extension mapping for cleaner handling.

Please assign this issue to me, I'll open a PR. Thanks!

Aryan-SINGH-GIT avatar Nov 29 '25 19:11 Aryan-SINGH-GIT