-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathirl.dart
64 lines (49 loc) · 1.71 KB
/
irl.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import "../document.dart";
import "./irl/parser.dart";
/// RFC3987 Internationalized Resource Identifier.
class KdlIRL extends KdlValue<Uri> {
/// Unicode value
String unicodeValue;
/// Unicode domain
String? unicodeDomain;
/// Unicode path
String? unicodePath;
/// Unicode search query
String? unicodeSearch;
/// Unicode hash value
String? unicodeHash;
/// Construct a new `KdlIRL`
KdlIRL(super.value, this.unicodeValue, this.unicodeDomain, this.unicodePath,
this.unicodeSearch, this.unicodeHash,
[super.type]);
KdlIRL._from(Irl value, [String? type])
: this(
Uri.parse(value.asciiValue),
value.unicodeValue,
value.unicodeDomain,
value.unicodePath,
value.unicodeSearch,
value.unicodeHash,
type);
/// Converts a `KdlString` into a `KdlIRL`
static KdlIRL? convert(KdlValue value, [String type = 'irl']) {
if (value is! KdlString) return null;
var irl = IrlParser(value.value, isReference: false).parse();
return KdlIRL._from(irl, type);
}
}
/// RFC3987 Internationalized Resource Identifier Reference.
class KdlIrlReference extends KdlIRL {
/// Constructs a new `KdlIRLReference`
KdlIrlReference(super.value, super.unicodeValue, super.unicodeDomain,
super.unicodePath, super.unicodeSearch, super.unicodeHash,
[super.type]);
KdlIrlReference._from(super.value, [super.type]) : super._from();
/// Converts a `KdlString` into a `KdlIRLReference`
static KdlIrlReference? convert(KdlValue value,
[String type = 'irl-reference']) {
if (value is! KdlString) return null;
var irl = IrlParser(value.value).parse();
return KdlIrlReference._from(irl, type);
}
}