File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,10 @@ export function stringToUUID(str: string): string {
28
28
}
29
29
30
30
export function addDebugIdToSource ( input : string , debugId : string ) : string {
31
- return input . replace ( / ( \n * ) ? ( \/ \/ # .+ \n * ) ? $ / , `\n//# debugId=${ debugId } \n$2` ) ;
31
+ return input . replace (
32
+ / \s * (?: \/ \/ # d e b u g I d = .+ ) ? \s * ( \/ \/ # .+ ) ? \s * $ / ,
33
+ `\n//# debugId=${ debugId } \n$1`
34
+ ) ;
32
35
}
33
36
34
37
export function addDebugIdToSourcemap ( input : string , debugId : string ) : string {
Original file line number Diff line number Diff line change @@ -12,6 +12,20 @@ describe("common", () => {
12
12
` ) ;
13
13
} ) ;
14
14
15
+ test ( "adds debugId to source with existing debugId" , ( ) => {
16
+ expect (
17
+ addDebugIdToSource (
18
+ `console.log('nothing')
19
+ //# debugId=302a139c-0c62-4af7-bfd3-03d083925e5e` ,
20
+ "000-000-000-000"
21
+ )
22
+ ) . toMatchInlineSnapshot ( `
23
+ "console.log('nothing')
24
+ //# debugId=000-000-000-000
25
+ "
26
+ ` ) ;
27
+ } ) ;
28
+
15
29
test ( "adds debugId to source with sourceMapURL" , ( ) => {
16
30
expect (
17
31
addDebugIdToSource (
@@ -26,4 +40,19 @@ describe("common", () => {
26
40
` ) ;
27
41
} ) ;
28
42
} ) ;
43
+
44
+ test ( "adds debugId to source with sourceMapURL and existing debugId" , ( ) => {
45
+ expect (
46
+ addDebugIdToSource (
47
+ `console.log('nothing');
48
+ //# debugId=302a139c-0c62-4af7-bfd3-03d083925e5e
49
+ //# sourceMappingURL=main.js.map` ,
50
+ "000-000-000-000"
51
+ )
52
+ ) . toMatchInlineSnapshot ( `
53
+ "console.log('nothing');
54
+ //# debugId=000-000-000-000
55
+ //# sourceMappingURL=main.js.map"
56
+ ` ) ;
57
+ } ) ;
29
58
} ) ;
You can’t perform that action at this time.
0 commit comments