Skip to content

Commit

Permalink
CORE: restrict url (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekachxaidze98 authored Nov 14, 2024
1 parent 5c4772d commit 0f3f570
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion api/data-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fetchMetadata = async (id, search_id) => {
const isUndefined = split?.some((item) => item === undefined)
const { data } = await requestV3(
// eslint-disable-next-line camelcase
`/data-providers/${id}${!isUndefined ? `?t=${search_id}` : ''}`
`/data-providers/${id}${!isUndefined || search_id ? `?t=${search_id}` : ''}`
)
return data
}
Expand Down
2 changes: 1 addition & 1 deletion api/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const fetchWorks = async (body) => {
const isUndefined = split?.some((item) => item === undefined)
const url = new URL(
// eslint-disable-next-line camelcase
`/v3/search/works${!isUndefined ? `?t=${search_id}` : ''}`,
`/v3/search/works${!isUndefined || search_id ? `?t=${search_id}` : ''}`,
process.env.API_URL
).href
const { data: dataWorks } = await apiRequest(url, {
Expand Down
2 changes: 1 addition & 1 deletion api/works.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fetchWork = async (id, search_id) => {
const isUndefined = split?.some((item) => item === undefined)
const url = new URL(
// eslint-disable-next-line camelcase
`/v3/works/${id}${!isUndefined ? `?t=${search_id}` : ''}`,
`/v3/works/${id}${!isUndefined || search_id ? `?t=${search_id}` : ''}`,
process.env.API_URL
).href

Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions templates/search/results.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const Results = ({ works, searchId }) =>
if (innerDownloadLink) return innerDownloadLink
return innerFullTextLink
}

return (
<SearchResult
id={`search-output-${id}`}
Expand All @@ -89,13 +90,17 @@ const Results = ({ works, searchId }) =>
metadataLink:
generateMetadataLink(metadataLink, searchId, id) ||
generateMetadataLink(displayLink, searchId, id),
fullTextLink: renderFullTextLink({
fullTextLink,
downloadLink,
modifiedReaderLink,
searchId,
id,
}),
fullTextLink:
!window.location.search.includes('author') &&
!window.location.pathname.includes('data-providers')
? renderFullTextLink({
fullTextLink,
downloadLink,
modifiedReaderLink,
searchId,
id,
})
: fullTextLink || readerLink || downloadLink,
dataProviders: dataProviders || [],
isRecommended: memberType?.billing_type === 'sustaining',
}}
Expand Down

0 comments on commit 0f3f570

Please sign in to comment.