Language: TypeScript
Label: safe
CWE: CWE-918 \u2014 Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.

Code:
module.exports = async (ctx) => {
    const { subdomain } = ctx.params;
    if (!isValidHost(subdomain)) {
        throw Error('Invalid subdomain');
    }
    const shopUrl = `https://${subdomain}.booth.pm`;

    let shopName;
    const items = [];
    for (let page = 1; page <= maxPages; page++) {
        const pageUrl = `${shopUrl}/items?page=${page}`;
        // eslint-disable-next-line no-await-in-loop
        const response = await got({
            method: 'get',
            url: pageUrl,
        });

        const data = response.data;

        const $ = cheerio.load(data);
        shopName = $('div.shop-name > span').text();
        const pageItems = $('li.item');

        if (pageItems.length === 0) {
            break;
        }

        for (let i = 0; i < pageItems.length; ++i) {
            const pageItem = pageItems[i];

            // extract item name
            const itemName = $('h2.item-name > a', pageItem).text();

            // extract item url
            const itemUrl = shopUrl + $('h2.item-name > a', pageItem).attr('href');

            // extract item preview url
            const itemPreviewUrl = $('div.swap-image > img', pageItem).attr('src');

            items.push({
                title: itemName,
                description: `<img src='${itemPreviewUrl}'/>`,
                link: itemUrl,
            });
        }
    }

    ctx.state.data = {
        title: shopName,
        link: shopUrl,
        description: shopName,
        allowEmpty: true,
        item: items,
    };
};