bare-url 2.0.7 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-url",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "WHATWG URL implementation for JavaScript",
5
5
  "main": "index.js",
6
6
  "files": [
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -19,13 +19,13 @@ target_sources(
19
19
  url
20
20
  INTERFACE
21
21
  include/url.h
22
+ include/url/character-set.h
23
+ include/url/infra.h
24
+ include/url/parse.h
25
+ include/url/percent-encode.h
26
+ include/url/serialize.h
27
+ include/url/type.h
22
28
  PRIVATE
23
- src/character-set.h
24
- src/infra.h
25
- src/parse.h
26
- src/percent-encode.h
27
- src/serialize.h
28
- src/type.h
29
29
  src/url.c
30
30
  )
31
31
 
@@ -72,6 +72,8 @@ install(TARGETS url_shared url_static)
72
72
 
73
73
  install(FILES include/url.h DESTINATION include)
74
74
 
75
+ install(DIRECTORY include/url DESTINATION include)
76
+
75
77
  if(PROJECT_IS_TOP_LEVEL)
76
78
  enable_testing()
77
79
  add_subdirectory(bench)
@@ -9,7 +9,7 @@
9
9
  #include <utf.h>
10
10
  #include <utf/string.h>
11
11
 
12
- #include "../include/url.h"
12
+ #include "../url.h"
13
13
  #include "character-set.h"
14
14
  #include "infra.h"
15
15
  #include "percent-encode.h"
@@ -4,7 +4,7 @@
4
4
  #include <utf.h>
5
5
  #include <utf/string.h>
6
6
 
7
- #include "../include/url.h"
7
+ #include "../url.h"
8
8
 
9
9
  static inline url_type_t
10
10
  url__type (const utf8_string_view_t scheme) {
@@ -12,7 +12,7 @@ extern "C" {
12
12
  typedef struct url_s url_t;
13
13
  typedef uint32_t url_component_t;
14
14
 
15
- static const url_component_t url_component_unset = (url_component_t) -1;
15
+ #define url_component_unset ((url_component_t) - 1);
16
16
 
17
17
  enum {
18
18
  url_has_opaque_path = 0x1,
@@ -64,41 +64,81 @@ struct url_s {
64
64
  } components;
65
65
  };
66
66
 
67
- void
68
- url_init (url_t *url);
67
+ inline void
68
+ url_init (url_t *url) {
69
+ url->flags = 0;
70
+ url->type = url_type_opaque;
71
+
72
+ url->components.scheme_end = 0;
73
+ url->components.username_end = 0;
74
+ url->components.host_start = 0;
75
+ url->components.host_end = 0;
76
+ url->components.port = url_component_unset;
77
+ url->components.path_start = 0;
78
+ url->components.query_start = url_component_unset;
79
+ url->components.fragment_start = url_component_unset;
80
+
81
+ utf8_string_init(&url->href);
82
+ }
83
+
84
+ inline void
85
+ url_destroy (url_t *url) {
86
+ utf8_string_destroy(&url->href);
87
+ }
69
88
 
70
- void
71
- url_destroy (url_t *url);
89
+ inline utf8_string_view_t
90
+ url_get_href (const url_t *url) {
91
+ return utf8_string_substring(&url->href, 0, url->href.len);
92
+ }
72
93
 
73
- int
74
- url_parse (url_t *url, const utf8_t *input, size_t len, const url_t *base);
94
+ inline utf8_string_view_t
95
+ url_get_scheme (const url_t *url) {
96
+ return utf8_string_substring(&url->href, 0, url->components.scheme_end);
97
+ }
98
+
99
+ inline utf8_string_view_t
100
+ url_get_username (const url_t *url) {
101
+ return utf8_string_substring(&url->href, url->components.scheme_end + 3 /* :// */, url->components.username_end);
102
+ }
75
103
 
76
- utf8_string_view_t
77
- url_get_href (const url_t *url);
104
+ inline utf8_string_view_t
105
+ url_get_password (const url_t *url) {
106
+ return utf8_string_substring(&url->href, url->components.username_end + 1 /* : */, url->components.host_start - 1 /* @ */);
107
+ }
78
108
 
79
- utf8_string_view_t
80
- url_get_scheme (const url_t *url);
109
+ inline utf8_string_view_t
110
+ url_get_host (const url_t *url) {
111
+ return utf8_string_substring(&url->href, url->components.host_start, url->components.host_end);
112
+ }
81
113
 
82
- utf8_string_view_t
83
- url_get_username (const url_t *url);
114
+ inline utf8_string_view_t
115
+ url_get_port (const url_t *url) {
116
+ return utf8_string_substring(&url->href, url->components.host_end + 1 /* : */, url->components.path_start);
117
+ }
84
118
 
85
- utf8_string_view_t
86
- url_get_password (const url_t *url);
119
+ inline utf8_string_view_t
120
+ url_get_path (const url_t *url) {
121
+ return utf8_string_substring(&url->href, url->components.path_start, url->components.query_start - 1 /* ? */);
122
+ }
87
123
 
88
- utf8_string_view_t
89
- url_get_host (const url_t *url);
124
+ inline utf8_string_view_t
125
+ url_get_query (const url_t *url) {
126
+ return utf8_string_substring(&url->href, url->components.query_start, url->components.fragment_start - 1 /* # */);
127
+ }
90
128
 
91
- utf8_string_view_t
92
- url_get_port (const url_t *url);
129
+ inline utf8_string_view_t
130
+ url_get_fragment (const url_t *url) {
131
+ return utf8_string_substring(&url->href, url->components.fragment_start, url->href.len);
132
+ }
93
133
 
94
- utf8_string_view_t
95
- url_get_path (const url_t *url);
134
+ #include "url/parse.h"
96
135
 
97
- utf8_string_view_t
98
- url_get_query (const url_t *url);
136
+ inline int
137
+ url_parse (url_t *url, const utf8_t *input, size_t len, const url_t *base) {
138
+ if (len == (size_t) -1) len = strlen((char *) input);
99
139
 
100
- utf8_string_view_t
101
- url_get_fragment (const url_t *url);
140
+ return url__parse(url, utf8_string_view_init(input, len), base);
141
+ }
102
142
 
103
143
  #ifdef __cplusplus
104
144
  }
@@ -4,78 +4,39 @@
4
4
  #include <utf/string.h>
5
5
 
6
6
  #include "../include/url.h"
7
- #include "parse.h"
8
7
 
9
- void
10
- url_init (url_t *url) {
11
- url->flags = 0;
12
- url->type = url_type_opaque;
8
+ extern void
9
+ url_init (url_t *url);
13
10
 
14
- url->components.scheme_end = 0;
15
- url->components.username_end = 0;
16
- url->components.host_start = 0;
17
- url->components.host_end = 0;
18
- url->components.port = url_component_unset;
19
- url->components.path_start = 0;
20
- url->components.query_start = url_component_unset;
21
- url->components.fragment_start = url_component_unset;
11
+ extern void
12
+ url_destroy (url_t *url);
22
13
 
23
- utf8_string_init(&url->href);
24
- }
14
+ extern utf8_string_view_t
15
+ url_get_href (const url_t *url);
25
16
 
26
- void
27
- url_destroy (url_t *url) {
28
- utf8_string_destroy(&url->href);
29
- }
17
+ extern utf8_string_view_t
18
+ url_get_scheme (const url_t *url);
30
19
 
31
- int
32
- url_parse (url_t *url, const utf8_t *input, size_t len, const url_t *base) {
33
- if (len == (size_t) -1) len = strlen((char *) input);
20
+ extern utf8_string_view_t
21
+ url_get_username (const url_t *url);
34
22
 
35
- return url__parse(url, utf8_string_view_init(input, len), base);
36
- }
23
+ extern utf8_string_view_t
24
+ url_get_password (const url_t *url);
37
25
 
38
- utf8_string_view_t
39
- url_get_href (const url_t *url) {
40
- return utf8_string_substring(&url->href, 0, url->href.len);
41
- }
26
+ extern utf8_string_view_t
27
+ url_get_host (const url_t *url);
42
28
 
43
- utf8_string_view_t
44
- url_get_scheme (const url_t *url) {
45
- return utf8_string_substring(&url->href, 0, url->components.scheme_end);
46
- }
29
+ extern utf8_string_view_t
30
+ url_get_port (const url_t *url);
47
31
 
48
- utf8_string_view_t
49
- url_get_username (const url_t *url) {
50
- return utf8_string_substring(&url->href, url->components.scheme_end + 3 /* :// */, url->components.username_end);
51
- }
32
+ extern utf8_string_view_t
33
+ url_get_path (const url_t *url);
52
34
 
53
- utf8_string_view_t
54
- url_get_password (const url_t *url) {
55
- return utf8_string_substring(&url->href, url->components.username_end + 1 /* : */, url->components.host_start - 1 /* @ */);
56
- }
35
+ extern utf8_string_view_t
36
+ url_get_query (const url_t *url);
57
37
 
58
- utf8_string_view_t
59
- url_get_host (const url_t *url) {
60
- return utf8_string_substring(&url->href, url->components.host_start, url->components.host_end);
61
- }
38
+ extern utf8_string_view_t
39
+ url_get_fragment (const url_t *url);
62
40
 
63
- utf8_string_view_t
64
- url_get_port (const url_t *url) {
65
- return utf8_string_substring(&url->href, url->components.host_end + 1 /* : */, url->components.path_start);
66
- }
67
-
68
- utf8_string_view_t
69
- url_get_path (const url_t *url) {
70
- return utf8_string_substring(&url->href, url->components.path_start, url->components.query_start - 1 /* ? */);
71
- }
72
-
73
- utf8_string_view_t
74
- url_get_query (const url_t *url) {
75
- return utf8_string_substring(&url->href, url->components.query_start, url->components.fragment_start - 1 /* # */);
76
- }
77
-
78
- utf8_string_view_t
79
- url_get_fragment (const url_t *url) {
80
- return utf8_string_substring(&url->href, url->components.fragment_start, url->href.len);
81
- }
41
+ extern int
42
+ url_parse (url_t *url, const utf8_t *input, size_t len, const url_t *base);
File without changes
File without changes
File without changes
File without changes