• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef SRC_NODE_URL_H_
2 #define SRC_NODE_URL_H_
3 
4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5 
6 #include <cinttypes>
7 #include "ada.h"
8 #include "aliased_buffer.h"
9 #include "node.h"
10 #include "node_snapshotable.h"
11 #include "util.h"
12 
13 #include <string>
14 
15 namespace node {
16 class ExternalReferenceRegistry;
17 
18 namespace url {
19 
20 enum url_update_action {
21   kProtocol = 0,
22   kHost = 1,
23   kHostname = 2,
24   kPort = 3,
25   kUsername = 4,
26   kPassword = 5,
27   kPathname = 6,
28   kSearch = 7,
29   kHash = 8,
30   kHref = 9,
31 };
32 
33 class BindingData : public SnapshotableObject {
34  public:
35   explicit BindingData(Realm* realm, v8::Local<v8::Object> obj);
36 
37   using InternalFieldInfo = InternalFieldInfoBase;
38 
39   SERIALIZABLE_OBJECT_METHODS()
40   SET_BINDING_ID(url_binding_data)
41 
42   void MemoryInfo(MemoryTracker* tracker) const override;
43   SET_SELF_SIZE(BindingData)
44   SET_MEMORY_INFO_NAME(BindingData)
45 
46   static void ToASCII(const v8::FunctionCallbackInfo<v8::Value>& args);
47   static void ToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args);
48 
49   static void DomainToASCII(const v8::FunctionCallbackInfo<v8::Value>& args);
50   static void DomainToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args);
51 
52   static void CanParse(const v8::FunctionCallbackInfo<v8::Value>& args);
53   static void Format(const v8::FunctionCallbackInfo<v8::Value>& args);
54   static void Parse(const v8::FunctionCallbackInfo<v8::Value>& args);
55   static void Update(const v8::FunctionCallbackInfo<v8::Value>& args);
56 
57   static void Initialize(v8::Local<v8::Object> target,
58                          v8::Local<v8::Value> unused,
59                          v8::Local<v8::Context> context,
60                          void* priv);
61   static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
62 
63  private:
64   static constexpr size_t kURLComponentsLength = 9;
65   AliasedUint32Array url_components_buffer_;
66 
67   void UpdateComponents(const ada::url_components& components,
68                         const ada::scheme::type type);
69 };
70 
71 std::string FromFilePath(const std::string_view file_path);
72 
73 }  // namespace url
74 
75 }  // namespace node
76 
77 #endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
78 
79 #endif  // SRC_NODE_URL_H_
80