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

View File

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

View File

@ -9,11 +9,12 @@ export default function(title: string, siteName?: string): string {
const x = escapeRegExp(siteName);
const patterns = [
`^(.+?)\s?[\-\|:・]\s?${x}$`
].map(p => new RegExp(p));
`^(.+?)\\s?[\\-\\|:・]\\s?${x}$`
];
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;
}
}