Skip to content

Commit

Permalink
Fixed lookup paths during source map construction (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-leuthaeuser authored Oct 13, 2023
1 parent d5ab9a9 commit f0ed1d5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/scala/io/shiftleft/js2cpg/parser/JsSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class JsSource(val srcDir: File, val projectDir: Path, val source: Source) {
val cleanedPath = FileUtils.cleanPath(sourceFileName)
// having "/" here is fine as JS source maps always have platform independent path separators
val lookupPath = if (cleanedPath.contains("/" + srcDir.name + "/")) {
cleanedPath.substring(cleanedPath.lastIndexOf("/" + srcDir.name + "/") + srcDir.name.length + 2)
cleanedPath.substring(cleanedPath.indexOf("/" + srcDir.name + "/") + srcDir.name.length + 2)
} else {
cleanedPath
}
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/typescriptsub/subc/typescriptsub/c.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("subc - c!");
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class TranspilationRunnerTest extends AnyWordSpec with Matchers {
s"subb${java.io.File.separator}nested${java.io.File.separator}a.ts",
s"subb${java.io.File.separator}nested${java.io.File.separator}b.ts",
s"subb${java.io.File.separator}nested${java.io.File.separator}other.js",
s"subc${java.io.File.separator}typescriptsub${java.io.File.separator}c.ts",
s"subb${java.io.File.separator}a.ts",
s"subb${java.io.File.separator}b.ts"
)
Expand Down

0 comments on commit f0ed1d5

Please sign in to comment.