Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed dump for cases when special URL characters in task name #1162

Merged
merged 1 commit into from
Feb 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cvat-core/src/server-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,9 @@
async function dumpAnnotations(id, name, format) {
const { backendAPI } = config;
const filename = name.replace(/\//g, '_');
let url = `${backendAPI}/tasks/${id}/annotations/${filename}?format=${format}`;
const baseURL = `${backendAPI}/tasks/${id}/annotations/${encodeURIComponent(filename)}`;
let query = `format=${encodeURIComponent(format)}`;
let url = `${baseURL}?${query}`;

return new Promise((resolve, reject) => {
async function request() {
Expand All @@ -569,7 +571,8 @@
if (response.status === 202) {
setTimeout(request, 3000);
} else {
url = `${url}&action=download`;
query = `${query}&action=download`;
Copy link
Contributor

@nglazov nglazov Feb 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to use some library, to work with query as object

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nglazov

Looks like overhead, to add library for such a minor case
What is more, similar functionality for working with query string is already part of native JS: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's good solution too
I mean, that better to work with objects instead of strings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense

url = `${baseURL}?${query}`;
resolve(url);
}
}).catch((errorData) => {
Expand Down