You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+62-2Lines changed: 62 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,8 @@ Table of Contents
39
39
-[Normalize URL](#normalize-url)
40
40
-[Domain Depth](#domain-depth)
41
41
-[Base64 Encode / Decode](#base64-encode--decode)
42
+
-[Validate URL](#validate-url)
43
+
-[Validate Domain](#validate-domain)
42
44
-[Get Extension Version](#get-extension-version)
43
45
-[Build Requirements](#build-requirements)
44
46
-[Debugging](#debugging)
@@ -731,6 +733,66 @@ D SELECT base64_decode(base64_encode('https://example.com')) AS roundtrip;
731
733
└─────────────────────┘
732
734
```
733
735
736
+
### Validate URL
737
+
738
+
The `is_valid_url` function checks whether a string is a well-formed URL. A valid URL must have a scheme (e.g., `http`, `https`, `ftp`), the `://` separator, and a non-empty host. Returns a `BOOLEAN`, `NULL` for `NULL` input.
739
+
740
+
```sql
741
+
D SELECT is_valid_url('https://example.com') AS valid;
742
+
┌─────────┐
743
+
│ valid │
744
+
│ boolean │
745
+
├─────────┤
746
+
│ true │
747
+
└─────────┘
748
+
749
+
D SELECT is_valid_url('example.com') AS valid;
750
+
┌─────────┐
751
+
│ valid │
752
+
│ boolean │
753
+
├─────────┤
754
+
│ false │
755
+
└─────────┘
756
+
757
+
D SELECT is_valid_url('https://[::1]:8080/path') AS valid;
758
+
┌─────────┐
759
+
│ valid │
760
+
│ boolean │
761
+
├─────────┤
762
+
│ true │
763
+
└─────────┘
764
+
```
765
+
766
+
### Validate Domain
767
+
768
+
The `is_valid_domain` function validates a domain name against RFC 1035 / RFC 1123 rules. Requires at least two labels, alphanumeric and hyphens only (no start/end with hyphen), max 63 chars per label, max 253 chars total, and a non-numeric TLD. Returns a `BOOLEAN`, `NULL` for `NULL` input.
769
+
770
+
```sql
771
+
D SELECT is_valid_domain('example.com') AS valid;
772
+
┌─────────┐
773
+
│ valid │
774
+
│ boolean │
775
+
├─────────┤
776
+
│ true │
777
+
└─────────┘
778
+
779
+
D SELECT is_valid_domain('sub.example.co.uk') AS valid;
780
+
┌─────────┐
781
+
│ valid │
782
+
│ boolean │
783
+
├─────────┤
784
+
│ true │
785
+
└─────────┘
786
+
787
+
D SELECT is_valid_domain('localhost') AS valid;
788
+
┌─────────┐
789
+
│ valid │
790
+
│ boolean │
791
+
├─────────┤
792
+
│ false │
793
+
└─────────┘
794
+
```
795
+
734
796
### Get Extension Version
735
797
736
798
You can use the `netquack_version` function to get the extension version.
@@ -773,12 +835,10 @@ Also, there will be stdout errors for background tasks like CURL.
773
835
-[ ] Save Tranco data as Parquet
774
836
-[ ] Implement GeoIP functionality
775
837
-[ ] Return default value for `get_tranco_rank`
776
-
-[ ] Implement `is_valid_url` function - Return whether a string is a well-formed URL
The `is_valid_url` function checks whether a string is a well-formed URL with a scheme, authority (host), and optional port/path/query/fragment. Returns a `BOOLEAN`.
18
+
19
+
A valid URL must have:
20
+
21
+
- A scheme (e.g., `http`, `https`, `ftp`, or any valid scheme)
22
+
- The `://` separator
23
+
- A non-empty host (domain name, IPv4, or bracketed IPv6)
24
+
25
+
```sql
26
+
D SELECT is_valid_url('https://example.com') AS valid;
27
+
┌─────────┐
28
+
│ valid │
29
+
│ boolean │
30
+
├─────────┤
31
+
│ true │
32
+
└─────────┘
33
+
```
34
+
35
+
```sql
36
+
D SELECT is_valid_url('https://example.com:8080/path?q=1#frag') AS valid;
0 commit comments