parse-path.js 739 B

123456789101112131415161718192021222324
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.parsePath = parsePath;
  6. function parsePath(path) {
  7. const hashIndex = path.indexOf('#');
  8. const queryIndex = path.indexOf('?');
  9. const hasQuery = queryIndex > -1 && (hashIndex < 0 || queryIndex < hashIndex);
  10. if (hasQuery || hashIndex > -1) {
  11. return {
  12. pathname: path.substring(0, hasQuery ? queryIndex : hashIndex),
  13. query: hasQuery ? path.substring(queryIndex, hashIndex > -1 ? hashIndex : undefined) : '',
  14. hash: hashIndex > -1 ? path.slice(hashIndex) : ''
  15. };
  16. }
  17. return {
  18. pathname: path,
  19. query: '',
  20. hash: ''
  21. };
  22. }
  23. //# sourceMappingURL=parse-path.js.map