diff --git a/source/Stargate-Model-Tests/WebOriginTest.class.st b/source/Stargate-Model-Tests/WebOriginTest.class.st index a1e1c66..9d82f0e 100644 --- a/source/Stargate-Model-Tests/WebOriginTest.class.st +++ b/source/Stargate-Model-Tests/WebOriginTest.class.st @@ -1,9 +1,27 @@ Class { #name : #WebOriginTest, #superclass : #TestCase, - #category : #'Stargate-Model-Tests-Routing' + #category : #'Stargate-Model-Tests-CORS' } +{ #category : #tests } +WebOriginTest >> testAsUrl [ + + | origin | + origin := 'http://example.com/' asWebOrigin. + + self assertUrl: origin asUrl equals: 'http://example.com' +] + +{ #category : #tests } +WebOriginTest >> testAsWebOrigin [ + + | origin | + origin := 'http://example.com/' asWebOrigin. + + self assert: origin asWebOrigin == origin +] + { #category : #tests } WebOriginTest >> testComparing [ @@ -25,6 +43,22 @@ WebOriginTest >> testComparing [ withMessageText: 'mailto:John.doe@example.com does not comply with a valid origin' ] +{ #category : #tests } +WebOriginTest >> testPrintString [ + + self + assert: 'http://example.com/' asWebOrigin printString + equals: 'http://example.com'; + assert: 'http://example.com:80/' asWebOrigin printString + equals: 'http://example.com'; + assert: 'http://example.com/path/file' asWebOrigin printString + equals: 'http://example.com'; + assert: + 'https://johndoe@www.example.com:123/forum/questions?id=1' + asWebOrigin printString + equals: 'https://www.example.com:123' +] + { #category : #tests } WebOriginTest >> testValidOrigins [ diff --git a/source/Stargate-Model/WebOrigin.class.st b/source/Stargate-Model/WebOrigin.class.st index 3373789..b026da3 100644 --- a/source/Stargate-Model/WebOrigin.class.st +++ b/source/Stargate-Model/WebOrigin.class.st @@ -47,6 +47,18 @@ WebOrigin >> = aWebOrigin [ ^ self asString = aWebOrigin asString ] +{ #category : #converting } +WebOrigin >> asUrl [ + + ^ url copy +] + +{ #category : #converting } +WebOrigin >> asWebOrigin [ + + ^ self +] + { #category : #comparing } WebOrigin >> hash [