Change objects to precise type and apply encodeURIComponent to url

Signed-off-by: ohjongsung <ohjongsung@gmail.com>
This commit is contained in:
ohjongsung
2023-06-12 15:49:59 +09:00
parent 058328d77d
commit c7d401f16a
@@ -29,8 +29,22 @@ const createPullRequest = async (opts: {
repo: string;
title: string;
description?: string;
toRef: object;
fromRef: object;
toRef: {
id: string;
displayId: string;
type: string;
latestCommit: string;
latestChangeset: string;
isDefault: boolean;
};
fromRef: {
id: string;
displayId: string;
type: string;
latestCommit: string;
latestChangeset: string;
isDefault: boolean;
};
authorization: string;
apiBaseUrl: string;
}) => {
@@ -66,7 +80,9 @@ const createPullRequest = async (opts: {
try {
response = await fetch(
`${apiBaseUrl}/projects/${project}/repos/${repo}/pull-requests`,
`${apiBaseUrl}/projects/${encodeURIComponent(
project,
)}/repos/${encodeURIComponent(repo)}/pull-requests`,
data,
);
} catch (e) {
@@ -104,7 +120,13 @@ const findBranches = async (opts: {
try {
response = await fetch(
`${apiBaseUrl}/projects/${project}/repos/${repo}/branches?boostMatches=true&filterText=${branchName}`,
`${apiBaseUrl}/projects/${encodeURIComponent(
project,
)}/repos/${encodeURIComponent(
repo,
)}/branches?boostMatches=true&filterText=${encodeURIComponent(
branchName,
)}`,
options,
);
} catch (e) {