mirror of
https://github.com/modrinth/code.git
synced 2026-08-28 10:34:53 +00:00
fix: game version filter in search using quotes instead of backticks (#6415)
This commit is contained in:
@@ -484,7 +484,7 @@ export function useSearch(
|
||||
}
|
||||
orGroups[field].push(val)
|
||||
} else {
|
||||
parts.push(`${field} = ${enquoteNonBools(val)}`)
|
||||
parts.push(`${field} = ${formatSearchFilterValue(val)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -492,15 +492,15 @@ export function useSearch(
|
||||
for (const [field, values] of Object.entries(orGroups)) {
|
||||
if (values.length === 1) {
|
||||
const val = values[0]
|
||||
parts.push(`${field} = ${enquoteNonBools(val)}`)
|
||||
parts.push(`${field} = ${formatSearchFilterValue(val)}`)
|
||||
} else {
|
||||
const quoted = values.map(enquoteNonBools).join(', ')
|
||||
const quoted = values.map(formatSearchFilterValue).join(', ')
|
||||
parts.push(`${field} IN [${quoted}]`)
|
||||
}
|
||||
}
|
||||
|
||||
for (const [field, values] of Object.entries(negativeByType)) {
|
||||
const quoted = values.map(enquoteNonBools).join(', ')
|
||||
const quoted = values.map(formatSearchFilterValue).join(', ')
|
||||
parts.push(`${field} NOT IN [${quoted}]`)
|
||||
}
|
||||
|
||||
@@ -514,11 +514,11 @@ export function useSearch(
|
||||
for (const envGroup of getEnvironmentFilterGroups(client, server)) {
|
||||
if (envGroup.length === 1) {
|
||||
const [field, val] = envGroup[0].split(':')
|
||||
parts.push(`${field} = ${enquoteNonBools(val)}`)
|
||||
parts.push(`${field} = ${formatSearchFilterValue(val)}`)
|
||||
} else if (envGroup.length > 1) {
|
||||
const conditions = envGroup.map((f) => {
|
||||
const [field, val] = f.split(':')
|
||||
return `${field} = ${enquoteNonBools(val)}`
|
||||
return `${field} = ${formatSearchFilterValue(val)}`
|
||||
})
|
||||
parts.push(`(${conditions.join(' OR ')})`)
|
||||
}
|
||||
@@ -527,9 +527,9 @@ export function useSearch(
|
||||
// Project types
|
||||
const mappedProjectTypes = projectTypes.value.map(mapProjectTypeToSearch)
|
||||
if (mappedProjectTypes.length === 1) {
|
||||
parts.push(`project_types = ${enquoteNonBools(mappedProjectTypes[0])}`)
|
||||
parts.push(`project_types = ${formatSearchFilterValue(mappedProjectTypes[0])}`)
|
||||
} else if (mappedProjectTypes.length > 1) {
|
||||
const quoted = mappedProjectTypes.map(enquoteNonBools).join(', ')
|
||||
const quoted = mappedProjectTypes.map(formatSearchFilterValue).join(', ')
|
||||
parts.push(`project_types IN [${quoted}]`)
|
||||
}
|
||||
|
||||
@@ -792,11 +792,11 @@ function getEnvironmentFilterGroups(client: boolean, server: boolean): string[][
|
||||
return groups
|
||||
}
|
||||
|
||||
function enquoteNonBools(value: string): string {
|
||||
export function formatSearchFilterValue(value: string): string {
|
||||
if (value === 'true' || value === 'false') {
|
||||
return value
|
||||
}
|
||||
return `"${value}"`
|
||||
return `\`${value}\``
|
||||
}
|
||||
|
||||
function getOptionValue(option: FilterOption, negative?: boolean): string {
|
||||
|
||||
Reference in New Issue
Block a user