This commit is contained in:
syuilo 2017-05-06 17:17:44 +09:00
parent 4cc6be225e
commit d774c992bf
3 changed files with 6 additions and 5 deletions

View File

@ -1,4 +1,4 @@
2.0.3 / unreleased 2.0.3 / 2017-05-06
------------------ ------------------
* Improve title cleanuping * Improve title cleanuping

View File

@ -1,6 +1,6 @@
{ {
"name": "summaly", "name": "summaly",
"version": "2.0.2", "version": "2.0.3",
"description": "Get web page's summary", "description": "Get web page's summary",
"author": "syuilo <i@syuilo.com>", "author": "syuilo <i@syuilo.com>",
"license": "MIT", "license": "MIT",

View File

@ -9,11 +9,12 @@ export default function(title: string, siteName?: string): string {
const x = escapeRegExp(siteName); const x = escapeRegExp(siteName);
const patterns = [ const patterns = [
`^(.+?)\s?[\-\|:・]\s?${x}$` `^(.+?)\\s?[\\-\\|:・]\\s?${x}$`
].map(p => new RegExp(p)); ];
for (let i = 0; i < patterns.length; i++) { for (let i = 0; i < patterns.length; i++) {
const [, match] = patterns[i].exec(title); const pattern = new RegExp(patterns[i]);
const [, match] = pattern.exec(title) || [null, null];
if (match) return match; if (match) return match;
} }
} }