|
1668 | 1668 | })();
|
1669 | 1669 |
|
1670 | 1670 |
|
1671 |
| - |
1672 | 1671 | /// xml-prune.js
|
1673 | 1672 | (function() {
|
1674 | 1673 | let selector = '{{1}}';
|
|
1739 | 1738 | })();
|
1740 | 1739 |
|
1741 | 1740 |
|
1742 |
| - |
1743 | 1741 | /// m3u-prune.js
|
1744 | 1742 | // https://en.wikipedia.org/wiki/M3U
|
1745 | 1743 | (function() {
|
|
1753 | 1751 | }
|
1754 | 1752 | const regexFromArg = arg => {
|
1755 | 1753 | if ( arg === '' ) { return /^/; }
|
1756 |
| - if ( /^\/.*\/$/.test(arg) ) { return new RegExp(arg.slice(1, -1)); } |
| 1754 | + const match = /^\/(.+)\/([gms]*)$/.exec(arg); |
| 1755 | + if ( match !== null ) { |
| 1756 | + let flags = match[2] || ''; |
| 1757 | + if ( flags.includes('m') ) { flags += 's'; } |
| 1758 | + return new RegExp(match[1], flags); |
| 1759 | + } |
1757 | 1760 | return new RegExp(
|
1758 | 1761 | arg.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*+/g, '.*?')
|
1759 | 1762 | );
|
|
1790 | 1793 | };
|
1791 | 1794 | const pruner = text => {
|
1792 | 1795 | if ( (/^\s*#EXTM3U/.test(text)) === false ) { return text; }
|
| 1796 | + if ( reM3u.multiline ) { |
| 1797 | + reM3u.lastIndex = 0; |
| 1798 | + for (;;) { |
| 1799 | + const match = reM3u.exec(text); |
| 1800 | + if ( match === null ) { break; } |
| 1801 | + const before = text.slice(0, match.index); |
| 1802 | + if ( before.length === 0 || /[\n\r]+\s*$/.test(before) ) { |
| 1803 | + const after = text.slice(match.index + match[0].length); |
| 1804 | + if ( after.length === 0 || /^\s*[\n\r]+/.test(after) ) { |
| 1805 | + text = before.trim() + '\n' + after.trim(); |
| 1806 | + reM3u.lastIndex = before.length + 1; |
| 1807 | + } |
| 1808 | + } |
| 1809 | + if ( reM3u.global === false ) { break; } |
| 1810 | + } |
| 1811 | + } |
1793 | 1812 | const lines = text.split(/\n\r|\n|\r/);
|
1794 | 1813 | for ( let i = 0; i < lines.length; i++ ) {
|
1795 | 1814 | if ( lines[i] === undefined ) { continue; }
|
|
1841 | 1860 | })();
|
1842 | 1861 |
|
1843 | 1862 |
|
1844 |
| - |
1845 | 1863 | /// href-sanitizer.js
|
1846 | 1864 | (function() {
|
1847 | 1865 | let selector = '{{1}}';
|
|
0 commit comments