Skip to content
Merged
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
20 changes: 20 additions & 0 deletions app/controllers/web/my-account/list-domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: BUSL-1.1
*/

const punycode = require('node:punycode');
const dayjs = require('dayjs-with-plugins');
const isSANB = require('is-string-and-not-blank');
const numeral = require('numeral');
Expand Down Expand Up @@ -118,6 +119,25 @@ async function listDomains(ctx, next) {

let { domains } = ctx.state;

//
// filter domains by domain name if query parameter is provided
//
if (isSANB(ctx.query.domain)) {
const domainQuery = ctx.query.domain.toLowerCase().trim();
// support both ASCII and Unicode domain names
const domainQueryASCII = punycode.toASCII(domainQuery);
const domainQueryUnicode = punycode.toUnicode(domainQuery);

domains = domains.filter((domain) => {
const domainName = domain.name.toLowerCase();
return (
domainName.includes(domainQuery) ||
domainName.includes(domainQueryASCII) ||
domainName.includes(domainQueryUnicode)
);
});
}

//
// starting November 1st we enforce API pagination on this endpoint
// (unless user opts in beforehand using ?pagination=true)
Expand Down
Loading