mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/RoboCommander.git
synced 2026-06-16 03:36:01 +00:00
Initial commit
This commit is contained in:
61
node_modules/history/PathUtils.js
generated
vendored
Normal file
61
node_modules/history/PathUtils.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
var addLeadingSlash = exports.addLeadingSlash = function addLeadingSlash(path) {
|
||||
return path.charAt(0) === '/' ? path : '/' + path;
|
||||
};
|
||||
|
||||
var stripLeadingSlash = exports.stripLeadingSlash = function stripLeadingSlash(path) {
|
||||
return path.charAt(0) === '/' ? path.substr(1) : path;
|
||||
};
|
||||
|
||||
var hasBasename = exports.hasBasename = function hasBasename(path, prefix) {
|
||||
return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
|
||||
};
|
||||
|
||||
var stripBasename = exports.stripBasename = function stripBasename(path, prefix) {
|
||||
return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
|
||||
};
|
||||
|
||||
var stripTrailingSlash = exports.stripTrailingSlash = function stripTrailingSlash(path) {
|
||||
return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
|
||||
};
|
||||
|
||||
var parsePath = exports.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
|
||||
};
|
||||
};
|
||||
|
||||
var createPath = exports.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