/** * Expands the user's editor/IDE URL template for the repository action. * * The template is opened with `Linking.openURL` only — the API token is never * part of the template or the resulting URL, so IDE auth stays separate. */ export interface EditorUrlParts { owner: string; name: string; cloneUrl?: string; htmlUrl?: string; } /** Replaces `{owner}`, `{repo}`, `{cloneUrl}` and `{htmlUrl}`, URI-encoding each value. */ export function buildEditorUrl(template: string, parts: EditorUrlParts): string { return template .split('{owner}') .join(encodeURIComponent(parts.owner)) .split('{repo}') .join(encodeURIComponent(parts.name)) .split('{cloneUrl}') .join(encodeURIComponent(parts.cloneUrl ?? '')) .split('{htmlUrl}') .join(encodeURIComponent(parts.htmlUrl ?? '')); }