1 #ifndef SRC_NODE_URL_H_ 2 #define SRC_NODE_URL_H_ 4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 19 #define PARSESTATES(XX) \ 23 XX(kSpecialRelativeOrAuthority) \ 24 XX(kPathOrAuthority) \ 27 XX(kSpecialAuthoritySlashes) \ 28 XX(kSpecialAuthorityIgnoreSlashes) \ 43 XX(URL_FLAGS_NONE, 0) \ 44 XX(URL_FLAGS_FAILED, 0x01) \ 45 XX(URL_FLAGS_CANNOT_BE_BASE, 0x02) \ 46 XX(URL_FLAGS_INVALID_PARSE_STATE, 0x04) \ 47 XX(URL_FLAGS_TERMINATED, 0x08) \ 48 XX(URL_FLAGS_SPECIAL, 0x10) \ 49 XX(URL_FLAGS_HAS_USERNAME, 0x20) \ 50 XX(URL_FLAGS_HAS_PASSWORD, 0x40) \ 51 XX(URL_FLAGS_HAS_HOST, 0x80) \ 52 XX(URL_FLAGS_HAS_PATH, 0x100) \ 53 XX(URL_FLAGS_HAS_QUERY, 0x200) \ 54 XX(URL_FLAGS_HAS_FRAGMENT, 0x400) 56 enum url_parse_state {
58 #define XX(name) name, 64 #define XX(name, val) name = val, 70 int32_t flags = URL_FLAGS_NONE;
78 std::vector<std::string> path;
83 static void Parse(
const char* input,
85 enum url_parse_state state_override,
88 const struct url_data* base,
91 URL(
const char* input,
const size_t len) {
92 Parse(input, len, kUnknownState, &
context_,
false,
nullptr,
false);
95 URL(
const char* input,
const size_t len,
const URL* base) {
97 Parse(input, len, kUnknownState,
99 &(base->context_),
true);
101 Parse(input, len, kUnknownState, &
context_,
false,
nullptr,
false);
104 URL(
const char* input,
const size_t len,
105 const char* base,
const size_t baselen) {
106 if (base !=
nullptr && baselen > 0) {
107 URL _base(base, baselen);
108 Parse(input, len, kUnknownState,
110 &(_base.context_),
true);
112 Parse(input, len, kUnknownState, &
context_,
false,
nullptr,
false);
116 explicit URL(std::string input) :
117 URL(input.c_str(), input.length()) {}
119 URL(std::string input,
const URL* base) :
120 URL(input.c_str(), input.length(), base) {}
122 URL(std::string input, std::string base) :
123 URL(input.c_str(), input.length(), base.c_str(), base.length()) {}
133 const std::string& protocol()
const {
137 const std::string& username()
const {
141 const std::string& password()
const {
145 const std::string&
host()
const {
149 const std::string& query()
const {
153 const std::string& fragment()
const {
168 std::string ToFilePath();
170 const Local<Value> ToObject(Environment* env)
const;
180 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 182 #endif // SRC_NODE_URL_H_
Persistent< Context > context_