Skip to content

Commit f0ed1d5

Browse files
Fixed lookup paths during source map construction (#306)
1 parent d5ab9a9 commit f0ed1d5

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

src/main/scala/io/shiftleft/js2cpg/parser/JsSource.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class JsSource(val srcDir: File, val projectDir: Path, val source: Source) {
9999
val cleanedPath = FileUtils.cleanPath(sourceFileName)
100100
// having "/" here is fine as JS source maps always have platform independent path separators
101101
val lookupPath = if (cleanedPath.contains("/" + srcDir.name + "/")) {
102-
cleanedPath.substring(cleanedPath.lastIndexOf("/" + srcDir.name + "/") + srcDir.name.length + 2)
102+
cleanedPath.substring(cleanedPath.indexOf("/" + srcDir.name + "/") + srcDir.name.length + 2)
103103
} else {
104104
cleanedPath
105105
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("subc - c!");

src/test/scala/io/shiftleft/js2cpg/preprocessing/TranspilationRunnerTest.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ class TranspilationRunnerTest extends AnyWordSpec with Matchers {
164164
s"subb${java.io.File.separator}nested${java.io.File.separator}a.ts",
165165
s"subb${java.io.File.separator}nested${java.io.File.separator}b.ts",
166166
s"subb${java.io.File.separator}nested${java.io.File.separator}other.js",
167+
s"subc${java.io.File.separator}typescriptsub${java.io.File.separator}c.ts",
167168
s"subb${java.io.File.separator}a.ts",
168169
s"subb${java.io.File.separator}b.ts"
169170
)

0 commit comments

Comments
 (0)