mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/RoboCommander.git
synced 2026-06-16 08:16:01 +00:00
Initial commit
This commit is contained in:
58
node_modules/history/es/PathUtils.js
generated
vendored
Normal file
58
node_modules/history/es/PathUtils.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
export var addLeadingSlash = function addLeadingSlash(path) {
|
||||
return path.charAt(0) === '/' ? path : '/' + path;
|
||||
};
|
||||
|
||||
export var stripLeadingSlash = function stripLeadingSlash(path) {
|
||||
return path.charAt(0) === '/' ? path.substr(1) : path;
|
||||
};
|
||||
|
||||
export var hasBasename = function hasBasename(path, prefix) {
|
||||
return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
|
||||
};
|
||||
|
||||
export var stripBasename = function stripBasename(path, prefix) {
|
||||
return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
|
||||
};
|
||||
|
||||
export var stripTrailingSlash = function stripTrailingSlash(path) {
|
||||
return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
|
||||
};
|
||||
|
||||
export var parsePath = function parsePath(path) {
|
||||
var pathname = path || '/';
|
||||
var search = '';
|
||||
var hash = '';
|
||||
|
||||
var hashIndex = pathname.indexOf('#');
|
||||
if (hashIndex !== -1) {
|
||||
hash = pathname.substr(hashIndex);
|
||||
pathname = pathname.substr(0, hashIndex);
|
||||
}
|
||||
|
||||
var searchIndex = pathname.indexOf('?');
|
||||
if (searchIndex !== -1) {
|
||||
search = pathname.substr(searchIndex);
|
||||
pathname = pathname.substr(0, searchIndex);
|
||||
}
|
||||
|
||||
return {
|
||||
pathname: pathname,
|
||||
search: search === '?' ? '' : search,
|
||||
hash: hash === '#' ? '' : hash
|
||||
};
|
||||
};
|
||||
|
||||
export var createPath = function createPath(location) {
|
||||
var pathname = location.pathname,
|
||||
search = location.search,
|
||||
hash = location.hash;
|
||||
|
||||
|
||||
var path = pathname || '/';
|
||||
|
||||
if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search;
|
||||
|
||||
if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash;
|
||||
|
||||
return path;
|
||||
};
|
||||
Reference in New Issue
Block a user