File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -84,3 +84,19 @@ extension UUID: Value {
84
84
}
85
85
86
86
}
87
+
88
+ extension URL : Value {
89
+
90
+ public static var declaredDatatype : String {
91
+ String . declaredDatatype
92
+ }
93
+
94
+ public static func fromDatatypeValue( _ stringValue: String ) -> URL {
95
+ URL ( string: stringValue) !
96
+ }
97
+
98
+ public var datatypeValue : String {
99
+ absoluteString
100
+ }
101
+
102
+ }
Original file line number Diff line number Diff line change @@ -26,4 +26,15 @@ class FoundationTests: XCTestCase {
26
26
XCTAssertEqual ( UUID ( uuidString: " 4ABE10C9-FF12-4CD4-90C1-4B429001BAD3 " ) , uuid)
27
27
}
28
28
29
+ func testURLFromString( ) {
30
+ let string = " http://foo.com "
31
+ let url = URL . fromDatatypeValue ( string)
32
+ XCTAssertEqual ( URL ( string: string) , url)
33
+ }
34
+
35
+ func testStringFromURL( ) {
36
+ let url = URL ( string: " http://foo.com " ) !
37
+ let string = url. datatypeValue
38
+ XCTAssertEqual ( " http://foo.com " , string)
39
+ }
29
40
}
You can’t perform that action at this time.
0 commit comments