Comparing version 1.0.1 to 1.0.2
@@ -450,10 +450,17 @@ 'use strict'; | ||
const base = basename(path, ext); | ||
const regex = new RegExp(`^${escapeRegExp(base)}-(\\d+)${escapeRegExp(ext)}$`); | ||
const regex = new RegExp(`^${escapeRegExp(base)}(?:-(\\d+))?${escapeRegExp(ext)}$`); | ||
let num = -1; | ||
const num = files.reduce((_num, item) => { | ||
const match = regex.exec(item); | ||
for (let i = 0, len = files.length; i < len; i++) { | ||
const item = files[i]; | ||
if (!regex.test(item)) continue; | ||
return match != null ? Math.max(parseInt(match[1], 10), _num) : _num; | ||
}, -1); | ||
const match = item.match(regex); | ||
const matchNum = match[1] ? parseInt(match[1], 10) : 0; | ||
if (matchNum > num) { | ||
num = matchNum; | ||
} | ||
} | ||
return join(dirname(path), `${base}-${num + 1}${ext}`); | ||
@@ -460,0 +467,0 @@ } |
{ | ||
"name": "hexo-fs", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "File system module for Hexo.", | ||
@@ -5,0 +5,0 @@ "main": "lib/fs", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
22990
507
0