/** * Read an explicit ref from the `ref` query parameter or a `#ref` suffix. `?ref=` wins when both are present. * These are the only way to pass a branch name with slashes, which a /tree/ URL alone can't express. * @param url The URL to read (scheme optional) * @returns The decoded ref, if one was given */ export declare function getExplicitRef(url: string): string | undefined; /** * Count how many raw path segments after /tree/ make up the ref. * With an explicit ref, segments are consumed while their decoded join matches it, so fully, partly, * or un-encoded slashes all work. With no match, one segment is the tree ref and the explicit ref overrides it. * @param segments Raw path segments starting at the ref, e.g. ['feature', 'foo', 'templates'] or ['feature%2Ffoo', 'templates'] * @param explicitRef Ref from `?ref=` or `#ref` * @returns The number of segments that make up the ref */ export declare function countRefSegments(segments: string[], explicitRef?: string): number; /** * Build the `/tree/` part of a GitHub URL, plus a `?ref=` query when the ref can't round-trip through the path alone * (slashes or characters that need encoding). * @param ref The ref * @returns The encoded ref path and the query string (empty when not needed) */ export declare function encodeRef(ref: string): { path: string; query: string; }; export declare function safeDecode(segment: string): string; /** * Format a ref as a giget `#ref` suffix. giget only reads letters, numbers and `-_./@` in a ref and cuts it off at * anything else, which would quietly download a different branch, so those refs are refused. * @param ref The ref, if any * @returns `#ref`, or an empty string when there's no ref * @throws Error if giget can't download the ref as written */ export declare function gigetRefSuffix(ref?: string): string;