1 |
|
2 | 'use strict';
|
3 |
|
4 | const testExpression = /(^|\/|\\)(?:((?:u[0-9a-f]{4,6},?)+)-)(.+)\.svg$/i;
|
5 |
|
6 | function fileSorter(fileA, fileB) {
|
7 | const hasUnicodeA = testExpression.test(fileA);
|
8 | const hasUnicodeB = testExpression.test(fileB);
|
9 |
|
10 | if (hasUnicodeA == hasUnicodeB) {
|
11 |
|
12 | const fileA_ = fileA.substr(0, fileA.lastIndexOf('.'));
|
13 | const fileB_ = fileB.substr(0, fileB.lastIndexOf('.'));
|
14 | return fileA_ < fileB_ ? -1 : 1;
|
15 | } else {
|
16 |
|
17 | return (hasUnicodeA ? 0 : 1) - (hasUnicodeB ? 0 : 1);
|
18 | }
|
19 | }
|
20 |
|
21 | module.exports = fileSorter;
|