#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "urls.h"

using std::cin;
using std::cout;
using std::endl;
using std::sort;
using std::string;
using std::vector;

int main() {
    // 输入文本
    cout << "输入一段文本: ";
    string input;
    std::getline(cin, input);

    // 提取所有 URL
    vector<string> urls = find_urls(input);

    // 筛选出以 http:// 或 https:// 开头的 URL
    vector<string> http_urls;
    for (const string& url : urls) {
        if (url.find("http://") == 0 || url.find("https://") == 0) {
            http_urls.push_back(url);
        }
    }

    // 按字母顺序排序
    sort(http_urls.begin(), http_urls.end());

    // 输出结果
    cout << "排序后的 HTTP URLs:" << endl;
    for (const string& url : http_urls) {
        cout << url << endl;
    }

    return 0;
}
