Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Resolved conflicts by taking GitHub versions for: - .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml Kept deploy.sh updated to: - Pull from GitHub (primary source) - Push to Gitea (push-mirror) - Build from site/ directory (GitHub structure) Co-Authored-By: Paperclip <noreply@paperclip.ing>
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
/**
|
|
* Given a path this function will find the pathname, query and hash and return
|
|
* them. This is useful to parse full paths on the client side.
|
|
* @param path A path to parse e.g. /foo/bar?id=1#hash
|
|
*/ "use strict";
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
Object.defineProperty(exports, "parsePath", {
|
|
enumerable: true,
|
|
get: function() {
|
|
return parsePath;
|
|
}
|
|
});
|
|
function parsePath(path) {
|
|
const hashIndex = path.indexOf('#');
|
|
const queryIndex = path.indexOf('?');
|
|
const hasQuery = queryIndex > -1 && (hashIndex < 0 || queryIndex < hashIndex);
|
|
if (hasQuery || hashIndex > -1) {
|
|
return {
|
|
pathname: path.substring(0, hasQuery ? queryIndex : hashIndex),
|
|
query: hasQuery ? path.substring(queryIndex, hashIndex > -1 ? hashIndex : undefined) : '',
|
|
hash: hashIndex > -1 ? path.slice(hashIndex) : ''
|
|
};
|
|
}
|
|
return {
|
|
pathname: path,
|
|
query: '',
|
|
hash: ''
|
|
};
|
|
}
|
|
|
|
//# sourceMappingURL=parse-path.js.map
|