Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
♻️ Allow uppercase sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Oct 31, 2020
1 parent 0dc4b42 commit 560c03a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pipes/order-by.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export class OrderByPipe implements PipeTransform {
const orderBy: Record<string, 'asc' | 'desc'> = {};
rules.forEach((rule) => {
const [key, order] = rule.split(' ') as [string, 'asc' | 'desc'];
if (!['asc', 'desc'].includes(order)) throw new Error();
orderBy[key] = order;
if (!['asc', 'desc'].includes(order.toLocaleLowerCase()))
throw new Error('Order should be "ASC" or "DESC"');
orderBy[key] = order.toLocaleLowerCase() as 'asc' | 'desc';
});
return orderBy;
} catch (_) {
Expand Down

0 comments on commit 560c03a

Please sign in to comment.