Make issue suggestion work for all editors (#33340)
And do not handle special keys when the text-expander popup exists
This commit is contained in:
parent
46d1e91aed
commit
2cb3946496
5 changed files with 34 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
|||
import {decode, encode} from 'uint8-to-base64';
|
||||
import type {IssuePageInfo, IssuePathInfo} from './types.ts';
|
||||
import type {IssuePageInfo, IssuePathInfo, RepoOwnerPathInfo} from './types.ts';
|
||||
|
||||
// transform /path/to/file.ext to file.ext
|
||||
export function basename(path: string): string {
|
||||
|
@ -32,16 +32,17 @@ export function stripTags(text: string): string {
|
|||
}
|
||||
|
||||
export function parseIssueHref(href: string): IssuePathInfo {
|
||||
// FIXME: it should use pathname and trim the appSubUrl ahead
|
||||
const path = (href || '').replace(/[#?].*$/, '');
|
||||
const [_, ownerName, repoName, pathType, indexString] = /([^/]+)\/([^/]+)\/(issues|pulls)\/([0-9]+)/.exec(path) || [];
|
||||
return {ownerName, repoName, pathType, indexString};
|
||||
}
|
||||
|
||||
export function parseIssueNewHref(href: string): IssuePathInfo {
|
||||
const path = (href || '').replace(/[#?].*$/, '');
|
||||
const [_, ownerName, repoName, pathTypeField] = /([^/]+)\/([^/]+)\/(issues\/new|compare\/.+\.\.\.)/.exec(path) || [];
|
||||
const pathType = pathTypeField ? (pathTypeField.startsWith('issues/new') ? 'issues' : 'pulls') : undefined;
|
||||
return {ownerName, repoName, pathType};
|
||||
export function parseRepoOwnerPathInfo(pathname: string): RepoOwnerPathInfo {
|
||||
const appSubUrl = window.config.appSubUrl;
|
||||
if (appSubUrl && pathname.startsWith(appSubUrl)) pathname = pathname.substring(appSubUrl.length);
|
||||
const [_, ownerName, repoName] = /([^/]+)\/([^/]+)/.exec(pathname) || [];
|
||||
return {ownerName, repoName};
|
||||
}
|
||||
|
||||
export function parseIssuePageInfo(): IssuePageInfo {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue