Skip to content

Commit d13a3b9

Browse files
authored
fix: escapeAssertion is compatible with safari (#444)
Signed-off-by: nodece <nodeces@gmail.com>
1 parent 412c014 commit d13a3b9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/util/util.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717

1818
import { mustGetDefaultFileSystem } from '../persist';
1919

20+
const escapeAssertionReg = new RegExp(/(^|[^A-Za-z0-9_])([rp])[0-9]*\./g);
21+
2022
function escapeAssertion(s: string): string {
21-
s = s.replace(/(?<!\w)r[0-9]*\./g, (match) => {
22-
return match.replace('.', '_');
23-
});
24-
s = s.replace(/(?<!\w)p[0-9]*\./g, (match) => {
25-
return match.replace('.', '_');
23+
s = s.replace(escapeAssertionReg, (match, p1, p2) => {
24+
return p1 + p2 + match.substring(p1.length + p2.length).replace('.', '_');
2625
});
2726
return s;
2827
}

0 commit comments

Comments
 (0)