1import ob from 'urbit-ob';
2import { ensurePatFormat, ensureSigPrefix } from 'form/formatters';
3import { patp2dec } from './patp2dec';
6 * pull the implied ticket and point from the #hash in the url
8// e.g., https://bridge.urbit.org/#widweb-tipfep-sabnux-nispec-sampel-palnet
11// ~widweb-tipfep-sabnux-nispec
13// Example tickets + points (Activation Flow):
14// ~widweb-tipfep-sabnux-nispec-sampel
15// ~widweb-tipfep-sabnux-nispec-sampel-palnet
16const VALID_TICKET_REGEX = /^~(?:[[a-z]{6}-){3}[a-z]{6}/;
17const VALID_TICKET_AND_POINT_REGEX = /^~([a-z]{6}-){4}([a-z-]{6,13})/;
18const CAPTURE_TICKET_REGEX = /^~((?:[[a-z]{6}-){3}[a-z]{6})/;
19const CAPTURE_POINT_REGEX = /^~(?:(?:[[a-z]{6}-){3}[a-z]{6}-{1})([a-z-]{6,13})/;
21export default function useImpliedTicket() {
22 const hash = window.location.hash.slice(1);
23 const pat = ensurePatFormat(hash);
24 const impliedTicket = VALID_TICKET_REGEX.test(pat)
25 ? pat.match(CAPTURE_TICKET_REGEX)![0]
28 const impliedPatp = VALID_TICKET_AND_POINT_REGEX.test(pat)
29 ? ensureSigPrefix(pat.match(CAPTURE_POINT_REGEX)![1])
34 impliedPatp && ob.isValidPatq(impliedPatp) ? patp2dec(impliedPatp) : null,
36 impliedPatp && ob.isValidPatq(impliedPatp) ? impliedPatp : null,
38 impliedTicket && ob.isValidPatq(impliedTicket) ? impliedTicket : null,
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list