Creating type setters an test methods. Modifying url setter-checker.

This commit is contained in:
ruidajo 2024-05-26 17:42:12 -05:00
parent 33fa7599b9
commit 26a7f763d1

View File

@ -32,17 +32,61 @@ InstagramUrl >> initialize [
]
{ #category : 'testing' }
InstagramUrl >> isRootUrl [
| segments |
self type = 'root' ifFalse: [
segments := self url segments.
segments ifNotNil: [ segments isEmpty ifFalse: [ ^ segments first = $/ ]].
^ true
].
^ true
]
{ #category : 'testing' }
InstagramUrl >> isUserUrl [
| segments |
self type = 'user' ifFalse: [
segments := self url segments.
segments size = 1 ifFalse: [^ segments second = $/].
^ true
].
^ true
]
{ #category : 'opening' }
InstagramUrl >> openWithoutTracking [
WebBrowser openOn: self urlWithoutTracking
]
{ #category : 'initialization' }
InstagramUrl >> setTypeByUrl [
self isRootUrl ifTrue: [ type := 'root'. ^ self ].
self isUserUrl ifTrue: [ type := 'user'. ^ self ].
type := 'UndefinedType'.
^ self
]
{ #category : 'accessing' }
InstagramUrl >> type [
^ type
]
{ #category : 'accessing' }
InstagramUrl >> type: aType [
(self urlTypes includes: aType) ifTrue: [
type := aType.
^ self ].
UIManager default inform:
'" ' , aType , ' " it''s not a correct type. Setting automatic from url.'.
^ self setTypeByUrl
]
{ #category : 'accessing' }
InstagramUrl >> url [
@ -50,9 +94,18 @@ InstagramUrl >> url [
]
{ #category : 'accessing' }
InstagramUrl >> url: aURL [
url := aURL
InstagramUrl >> url: anURLString [
| urlCheck |
(anURLString includesSubstring: 'instagram.com')
ifFalse: [ UIManager default inform: '" ', anURLString, ' " it''s not an instagram URL.'.
url := self url.
^ self].
urlCheck := anURLString asUrl.
urlCheck hasHost ifFalse: [ urlCheck host: urlCheck segments first.
urlCheck removeFirstPathSegment. ].
urlCheck hasScheme ifFalse: [ urlCheck scheme: 'https' ].
url := urlCheck
]
{ #category : 'accessing - data' }