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

fix(entities-shared): exact match should strip trailing slash #1744

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('useFetchUrlBuilder()', () => {
query: 'testQuery',
}

expect(builder(query)).toBe('http://foo.bar/entity/testQuery/')
expect(builder(query)).toBe('http://foo.bar/entity/testQuery')
})

it('should apply correct query schema for konnect when isExactMatch is not activated', () => {
Expand Down Expand Up @@ -89,6 +89,6 @@ describe('useFetchUrlBuilder()', () => {
query: 'testQuery',
}

expect(builder(query)).toBe('http://foo.bar/entity/testQuery/')
expect(builder(query)).toBe('http://foo.bar/entity/testQuery')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function useFetchUrlBuilder(
// 2) kongManager usage with _config.value.isExactMatch === true
urlWithParams.search = '' // trim any query params
urlWithParams = _config.value.isExactMatch
? new URL(`${urlWithParams.href}/${query}/`)
? new URL(`${urlWithParams.href}/${query}`)
: new URL(`${urlWithParams.href}?filter[name][contains]=${query}`)
} else {
// handle kongManager usage with _config.value.isExactMatch === false
Expand Down
16 changes: 12 additions & 4 deletions packages/entities/entities-shared/src/types/entity-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@ interface BaseFilterConfig {
isExactMatch: boolean
}

/** Exact match filter configuration */
/**
* Exact match filter configuration
* FIXME: "Exact match" here is no longer accurate, in reality it works as an indicator
* to use a single input field for filtering.
*/
export interface ExactMatchFilterConfig extends BaseFilterConfig {
isExactMatch: true
/** Placeholder for the exact match filter input */
placeholder: string
}

/** Exact match filter fields */
/** Fuzzy match filter fields */
export interface FilterFields {
[key: string]: Field
}

/** Exact match filter schema */
/** Fuzzy match filter schema */
export interface FilterSchema {
[key: string]: {
/** Used in the filter dropdown to determine the type of input */
Expand All @@ -28,7 +32,11 @@ export interface FilterSchema {
}
}

/** Fuzzy match filter configuration */
/**
* Fuzzy match filter configuration
* FIXME: "Fuzzy match" here is no longer accurate, in reality it works as an indicator
* to use a relatively complex form for filtering.
*/
export interface FuzzyMatchFilterConfig extends BaseFilterConfig {
isExactMatch: false
/** Fuzzy match filter fields */
Expand Down
Loading