diff --git a/Instagram-Tests/InstagramUrlTest.class.st b/Instagram-Tests/InstagramUrlTest.class.st index 29a7f0d..b1e1190 100644 --- a/Instagram-Tests/InstagramUrlTest.class.st +++ b/Instagram-Tests/InstagramUrlTest.class.st @@ -1,24 +1,25 @@ Class { - #name : #InstagramUrlTest, - #superclass : #TestCase, - #category : #'Instagram-Tests' + #name : 'InstagramUrlTest', + #superclass : 'TestCase', + #category : 'Instagram-Tests', + #package : 'Instagram-Tests' } -{ #category : #tests } +{ #category : 'tests' } InstagramUrlTest >> testInstagramUrlInstanceCreation [ | i | i := InstagramUrl newURL: 'instagram.com'. self assert: i url asStringOrText equals: 'https://instagram.com/' ] -{ #category : #tests } +{ #category : 'tests' } InstagramUrlTest >> testNotInstagramUrl1 [ | i | i := InstagramUrl newURL: 'nstgrm.com'. self assert: i url asStringOrText equals: 'https://www.instagram.com/' ] -{ #category : #tests } +{ #category : 'tests' } InstagramUrlTest >> testNotInstagramUrl2 [ | i | i := InstagramUrl newURL: 'nstgrm.com'. diff --git a/Instagram-Tests/package.st b/Instagram-Tests/package.st index 3d65490..af6bae2 100644 --- a/Instagram-Tests/package.st +++ b/Instagram-Tests/package.st @@ -1 +1 @@ -Package { #name : #'Instagram-Tests' } +Package { #name : 'Instagram-Tests' } diff --git a/Instagram/InstagramUrl.class.st b/Instagram/InstagramUrl.class.st index 5ba4017..180f582 100644 --- a/Instagram/InstagramUrl.class.st +++ b/Instagram/InstagramUrl.class.st @@ -7,7 +7,8 @@ Class { #name : 'InstagramUrl', #superclass : 'Object', #instVars : [ - 'url' + 'url', + 'type' ], #category : 'Instagram', #package : 'Instagram' @@ -23,10 +24,10 @@ InstagramUrl class >> newURL: url [ { #category : 'initialization' } InstagramUrl >> initialize [ - | initial | - initial := 'https://www.instagram.com' asUrl. + super initialize. - self url: initial. + self url. + self type. ] @@ -36,10 +37,16 @@ InstagramUrl >> openWithoutTracking [ WebBrowser openOn: self urlWithoutTracking ] +{ #category : 'accessing' } +InstagramUrl >> type [ + + ^ type +] + { #category : 'accessing' } InstagramUrl >> url [ - ^ url + ^ url ifNil: [ url := 'https://instagram.com/' asUrl ] ] { #category : 'accessing' } @@ -48,17 +55,11 @@ InstagramUrl >> url: aURL [ url := aURL ] -{ #category : 'testing' } -InstagramUrl >> urlCheck: aURLString [ - | urlCheck | - (aURLString includesSubstring: 'instagram.com') - ifFalse: [ UIManager default inform: '" ', aURLString, ' " it''s not an instagram URL.'. - ^ self url]. - urlCheck := aURLString asUrl. - urlCheck hasHost ifFalse: [ urlCheck host: urlCheck segments first. - urlCheck removeFirstPathSegment. ]. - urlCheck hasScheme ifFalse: [ urlCheck scheme: 'https' ]. - ^ urlCheck +{ #category : 'accessing - data' } +InstagramUrl >> urlTypes [ + "I have the collection of correct types." + + ^ { 'root' . 'user' } ] { #category : 'accessing' }