Files
30-seconds-of-code/node_modules/gatsby-link/parse-path.js
2019-08-20 15:52:05 +02:00

29 lines
611 B
JavaScript

"use strict";
exports.__esModule = true;
exports.parsePath = 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
};
}