mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-07 05:52:57 +00:00
refactor: consistently handle leading slash
This commit is contained in:
15
src/api.ts
15
src/api.ts
@@ -145,7 +145,7 @@ export class Api {
|
||||
}
|
||||
|
||||
return this.makeGitLabAPIRequest(
|
||||
'/projects/' + projectId + '/labels',
|
||||
'projects/' + projectId + '/labels',
|
||||
{
|
||||
data: {
|
||||
color: color,
|
||||
@@ -164,7 +164,7 @@ export class Api {
|
||||
* @param title Title of the milestone to create
|
||||
*/
|
||||
public createMilestone(projectId: number, title: string): Promise<void> {
|
||||
return this.makeGitLabAPIRequest('/projects/' + projectId + '/milestones?title=' + title, {
|
||||
return this.makeGitLabAPIRequest('projects/' + projectId + '/milestones?title=' + title, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
@@ -193,7 +193,7 @@ export class Api {
|
||||
*/
|
||||
public deleteLabel(projectId: number, name: string): Promise<void> {
|
||||
return this.makeGitLabAPIRequest(
|
||||
'/projects/' + projectId + '/labels',
|
||||
'projects/' + projectId + '/labels',
|
||||
{
|
||||
data: {
|
||||
name: name,
|
||||
@@ -227,7 +227,7 @@ export class Api {
|
||||
}
|
||||
|
||||
return this.makeGitLabAPIRequest(
|
||||
'/projects/' + projectId + '/labels',
|
||||
'projects/' + projectId + '/labels',
|
||||
{
|
||||
data: {
|
||||
color: newValues.color,
|
||||
@@ -282,7 +282,7 @@ export class Api {
|
||||
*/
|
||||
public getFile(projectId: number, filePath: string, commitish: string): Promise<any> {
|
||||
return this.makeGitLabAPIRequest(
|
||||
'/projects/' + projectId + '/repository/files/' +
|
||||
'projects/' + projectId + '/repository/files/' +
|
||||
encodeURIComponent(filePath).replace('.', '%2E') + '/raw?ref=' + encodeURIComponent(commitish),
|
||||
);
|
||||
}
|
||||
@@ -385,7 +385,7 @@ export class Api {
|
||||
*/
|
||||
public getTags(projectId: number): Promise<Tag[]> {
|
||||
return this.makeGitLabAPIRequest(
|
||||
'/projects/' + projectId + '/repository/tags',
|
||||
'projects/' + projectId + '/repository/tags',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -396,6 +396,7 @@ export class Api {
|
||||
* @param _options HTTP method/verb
|
||||
*/
|
||||
public async makeGitLabAPIRequest(url: string, _options?: ApiRequestOptions): Promise<any> {
|
||||
// remove leading slash
|
||||
url = url.replace(/^\/+/g, '');
|
||||
|
||||
const options: ApiRequestOptions = {
|
||||
@@ -483,7 +484,7 @@ export class Api {
|
||||
*/
|
||||
public protectBranch(projectId: number, branch: string): Promise<Branch> {
|
||||
return this.makeGitLabAPIRequest(
|
||||
'/projects/' + projectId + '/repository/branches/' + branch + '/protect' +
|
||||
'projects/' + projectId + '/repository/branches/' + branch + '/protect' +
|
||||
'?developers_can_push=false&developers_can_merge=false',
|
||||
{
|
||||
method: 'PUT',
|
||||
|
||||
Reference in New Issue
Block a user