Projekt

Obecné

Profil

Stáhnout (909 Bajtů) Statistiky
| Větev: | Revize:
1
/*
2
	MIT License http://www.opensource.org/licenses/mit-license.php
3
	Author Tobias Koppers @sokra
4
*/
5
"use strict";
6

    
7
module.exports = function getPaths(path) {
8
	const parts = path.split(/(.*?[\\\/]+)/);
9
	const paths = [path];
10
	const seqments = [parts[parts.length - 1]];
11
	let part = parts[parts.length - 1];
12
	path = path.substr(0, path.length - part.length - 1);
13
	for(let i = parts.length - 2; i > 2; i -= 2) {
14
		paths.push(path);
15
		part = parts[i];
16
		path = path.substr(0, path.length - part.length) || "/";
17
		seqments.push(part.substr(0, part.length - 1));
18
	}
19
	part = parts[1];
20
	seqments.push(part);
21
	paths.push(part);
22
	return {
23
		paths: paths,
24
		seqments: seqments
25
	};
26
};
27

    
28
module.exports.basename = function basename(path) {
29
	const i = path.lastIndexOf("/"),
30
		j = path.lastIndexOf("\\");
31
	const p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
32
	if(p < 0) return null;
33
	const s = path.substr(p + 1);
34
	return s;
35
};
(37-37/39)