Skip to content

Commit ee6dbec

Browse files
authored
[DI] Handle different casing in probe file paths (#5188)
In case the file path provided by the user is a different casing than the one actually deployed, the tracer should still be able to match it and apply the probe.
1 parent dbe0b74 commit ee6dbec

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

packages/dd-trace/src/debugger/devtools_client/state.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ module.exports = {
2121
findScriptFromPartialPath (path) {
2222
if (!path) return null // This shouldn't happen, but better safe than sorry
2323

24+
path = path.toLowerCase()
25+
2426
const bestMatch = new Array(3)
2527
let maxMatchLength = -1
2628

@@ -33,7 +35,7 @@ module.exports = {
3335

3436
// Compare characters from the end
3537
while (i >= 0 && j >= 0) {
36-
const urlChar = url[i]
38+
const urlChar = url[i].toLowerCase()
3739
const pathChar = path[j]
3840

3941
// Check if both characters is a path boundary

packages/dd-trace/test/debugger/devtools_client/state.spec.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ describe('findScriptFromPartialPath', function () {
6363
it('prefixed with two unknown directories', testPath(`prefix1/prefix2/to/${filename}`))
6464
})
6565

66+
describe('case insensitive', function () {
67+
it('should match if the path is in lowercase', testPath(filename.toLowerCase()))
68+
69+
it('should match if the path is in uppercase', testPath(filename.toUpperCase()))
70+
})
71+
6672
describe('non-matching paths', function () {
6773
it('should not match if only part of a directory matches (at boundary)',
6874
testPathNoMatch(`path/o/${filename}`))
@@ -73,8 +79,6 @@ describe('findScriptFromPartialPath', function () {
7379
it('should not match if only part of a directory matches (root)', testPathNoMatch(`o/${filename}`))
7480

7581
it('should not match if only part of a file matches', testPathNoMatch(filename.slice(1)))
76-
77-
it('should not match if only difference is the letter casing', testPathNoMatch(filename.toUpperCase()))
7882
})
7983
})
8084

0 commit comments

Comments
 (0)