File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -84,3 +84,19 @@ extension UUID: Value {
8484 }
8585
8686}
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 {
2626 XCTAssertEqual ( UUID ( uuidString: " 4ABE10C9-FF12-4CD4-90C1-4B429001BAD3 " ) , uuid)
2727 }
2828
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+ }
2940}
You can’t perform that action at this time.
0 commit comments