aboutsummaryrefslogtreecommitdiff
path: root/src/links.cpp
blob: 7c1a0c6d578abc3315d229dc175509ec54bc776f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "links.h"
#include "utils.h"

namespace newsboat {
unsigned int Links::add_link(const std::string& url, LinkType type)
{
	bool found = false;
	unsigned int i = 1;
	for (const auto& l : links) {
		if (l.url == newsboat::utils::censor_url(url)) {
			found = true;
			break;
		}
		i++;
	}

	if (!found) {
		links.push_back({newsboat::utils::censor_url(url), type});
	} else if (links[i - 1].type == LinkType::HREF) {
		links[i - 1].type = type;
	}

	return i;
}
}