Because the exporter (decl.getSourceFile().fileName) always has slashes (/) in the path regardless of the OS.
Ex:
Mac: /Users/project/src/pages/A/B/C/D/name.tsx
Win: D:/project/src/pages/A/B/C/D/name.tsx
Therefore, it is necessary to hardcode the slash character (/) in the regex to get the correct result on the Windows environment.
Because the exporter (decl.getSourceFile().fileName) always has slashes (/) in the path regardless of the OS. Ex: Mac: /Users/project/src/pages/A/B/C/D/name.tsx Win: D:/project/src/pages/A/B/C/D/name.tsx
Therefore, it is necessary to hardcode the slash character (/) in the regex to get the correct result on the Windows environment.