Mercurial > irccd
comparison plugins/links/uri.hpp @ 768:d8bf53170fb6
Plugin links: fix various errors, closes #912 @2h
Import uriparser to decode URLs correctly with fragment and query support for a
better link decomposition.
Improve pre-check message to allow people writing text after the link, e.g:
http://example.org <- you should check this
Improve relocation.
Split code for better style.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 24 Oct 2018 21:05:00 +0200 |
parents | |
children | 8c44bbcbbab9 |
comparison
equal
deleted
inserted
replaced
767:a2db884f2e4b | 768:d8bf53170fb6 |
---|---|
1 /* | |
2 * uri.hpp -- simple uriparser based parser | |
3 * | |
4 * Copyright (c) 2013-2018 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #ifndef IRCCD_URI_HPP | |
20 #define IRCCD_URI_HPP | |
21 | |
22 /** | |
23 * \file uri.hpp | |
24 * \brief Simple uriparser based parser. | |
25 */ | |
26 | |
27 #include <optional> | |
28 #include <string> | |
29 | |
30 namespace irccd { | |
31 | |
32 /** | |
33 * \file uri.hpp | |
34 */ | |
35 struct uri { | |
36 std::string scheme; //!< scheme (e.g. http) | |
37 std::string host; //!< host (e.g. example.org) | |
38 std::string port; //!< port (e.g. 8080) | |
39 std::string path; //!< path (e.g. /foo/bar) | |
40 | |
41 /** | |
42 * Try to parse the uri from the link text. | |
43 * | |
44 * \param link the link | |
45 * \return the uri or nullopt if not parseable | |
46 */ | |
47 static auto parse(const std::string& link) noexcept -> std::optional<uri>; | |
48 }; | |
49 | |
50 } // !irccd | |
51 | |
52 #endif // !IRCCD_URI_HPP |