Browse Source

fix(iot-hub): keep the grouped query string well-formed without text

pull/16148/head
dshvaika 2 months ago
parent
commit
19cbfc403a
  1. 10
      ui-ngx/src/app/shared/models/iot-hub/iot-hub-version.models.ts

10
ui-ngx/src/app/shared/models/iot-hub/iot-hub-version.models.ts

@ -163,14 +163,16 @@ export class MpItemVersionQuery {
*/
public toGroupedQuery(): string {
const text = this.pageLink.textSearch?.trim();
let query = '?';
const parts: string[] = [];
if (text?.length) {
query += `textSearch=${encodeURIComponent(text)}&`;
parts.push(`textSearch=${encodeURIComponent(text)}`);
}
if (this.pageLink.sortOrder) {
query += `sortProperty=${this.pageLink.sortOrder.property}&`;
parts.push(`sortProperty=${this.pageLink.sortOrder.property}`);
}
return query + this.filtersToQuery();
// filtersToQuery() emits leading ampersands, which is what toQuery() needs after a page link;
// here they may be the whole query string, so the first one is dropped.
return `?${`${parts.join('&')}${this.filtersToQuery()}`.replace(/^&/, '')}`;
}
public toQuery(): string {

Loading…
Cancel
Save