Skip to content

Commit 9b32d48

Browse files
committed
Convert PCRE \A and \Z
1 parent 02ba514 commit 9b32d48

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

3-
## Next
3+
## 1.5.1
4+
*2021-08-14*
45
- Fixed PCRE regular expressions causing a crash.
56
- Fixed shebang lines not being fully checked.
67
- Fixed heuristics with two fallback languages not choosing just one of them.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "linguist-js",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.",
55
"main": "dist/index.js",
66
"bin": {

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ function pcre(regex: string): RegExp {
2222
finalRegex = finalRegex.replace(match, '');
2323
[...flags].forEach(flag => finalFlags.add(flag));
2424
}
25-
finalRegex = finalRegex.replace(/([*+]){2}/g, '$1');
25+
finalRegex = finalRegex
26+
.replace(/([*+]){2}/g, '$1') // ++ and *+ modifiers
27+
.replace(/\\A/g, '^').replace(/\\Z/g, '$') // start- and end-of-file markers
2628
return RegExp(finalRegex, [...finalFlags].join(''));
2729
}
2830

0 commit comments

Comments
 (0)