Skip to content

Commit

Permalink
CORE: url undefined check (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekachxaidze98 authored Nov 13, 2024
1 parent e080077 commit 5c4772d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion api/data-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ const requestV3 = (url, ...args) => request(`${API_V3_URL}${url}`, ...args)

// eslint-disable-next-line camelcase
const fetchMetadata = async (id, search_id) => {
const split = search_id?.split('-')
const isUndefined = split?.some((item) => item === undefined)
const { data } = await requestV3(
// eslint-disable-next-line camelcase
`/data-providers/${id}${search_id ? `?t=${search_id}` : ''}`
`/data-providers/${id}${!isUndefined ? `?t=${search_id}` : ''}`
)
return data
}
Expand Down
4 changes: 3 additions & 1 deletion api/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ const FileDownload = require('js-file-download')
export const fetchWorks = async (body) => {
// eslint-disable-next-line camelcase
const { search_id } = body
const split = search_id?.split('-')
const isUndefined = split?.some((item) => item === undefined)
const url = new URL(
// eslint-disable-next-line camelcase
`/v3/search/works${search_id ? `?t=${search_id}` : ''}`,
`/v3/search/works${!isUndefined ? `?t=${search_id}` : ''}`,
process.env.API_URL
).href
const { data: dataWorks } = await apiRequest(url, {
Expand Down
4 changes: 3 additions & 1 deletion api/works.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import apiRequest from './index'

// eslint-disable-next-line camelcase
const fetchWork = async (id, search_id) => {
const split = search_id?.split('-')
const isUndefined = split?.some((item) => item === undefined)
const url = new URL(
// eslint-disable-next-line camelcase
`/v3/works/${id}${search_id ? `?t=${search_id}` : ''}`,
`/v3/works/${id}${!isUndefined ? `?t=${search_id}` : ''}`,
process.env.API_URL
).href

Expand Down

0 comments on commit 5c4772d

Please sign in to comment.