提交 6b74e23c 编写于 作者: M Matt Bierner 提交者: GitHub

Relax Language First Line Match (#21586)

* Relax Language First Line Match

Fixes #21533

**Bug**
The first line pattern for a language currently requires the entire line to match. This does is different from how tools such as textmate use firstLineMatch

**Fix**
Relax this restriction so that any match is used

* Fix failing test
上级 9b91a229
......@@ -202,9 +202,8 @@ function guessMimeTypeByFirstline(firstLine: string): string {
continue;
}
// Make sure the entire line matches, not just a subpart.
let matches = firstLine.match(association.firstline);
if (matches && matches.length > 0 && matches[0].length === firstLine.length) {
if (matches && matches.length > 0) {
return association.mime;
}
}
......
......@@ -37,7 +37,7 @@ suite('Mime', () => {
guess = guessMimeTypes('Randomfile.noregistration', 'RegexesAreNice');
assert.deepEqual(guess, ['text/nice-regex', 'text/plain']);
guess = guessMimeTypes('Randomfile.noregistration', 'RegexesAreNiceee');
guess = guessMimeTypes('Randomfile.noregistration', 'RegexesAreNotNice');
assert.deepEqual(guess, ['application/unknown']);
guess = guessMimeTypes('Codefile', 'RegexesAreNice');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册