mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-29 08:54:30 -04:00
fix: namespace parsing in gitlab (#84)
* fix: namespace parsing in gitlab * test: add test for nested namespace --------- Co-authored-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
This commit is contained in:
parent
e7c9b4795b
commit
ed32d2275b
6 changed files with 538 additions and 109 deletions
|
@ -181,9 +181,18 @@ export default class GitLabClient implements GitClient {
|
|||
* @returns {{owner: string, project: string}}
|
||||
*/
|
||||
private extractMergeRequestData(mrUrl: string): {namespace: string, project: string, id: number} {
|
||||
const elems: string[] = mrUrl.replace("/-/", "/").split("/");
|
||||
const { pathname } = new URL(mrUrl);
|
||||
const elems: string[] = pathname.substring(1).replace("/-/", "/").split("/");
|
||||
let namespace = "";
|
||||
|
||||
for (let i = 0; i < elems.length - 3; i++) {
|
||||
namespace += elems[i] + "/";
|
||||
}
|
||||
|
||||
namespace = namespace.substring(0, namespace.length - 1);
|
||||
|
||||
return {
|
||||
namespace: elems[elems.length - 4],
|
||||
namespace: namespace,
|
||||
project: elems[elems.length - 3],
|
||||
id: parseInt(mrUrl.substring(mrUrl.lastIndexOf("/") + 1, mrUrl.length)),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue