Refactoring URL checking.

This commit is contained in:
ruidajo 2024-01-30 12:50:17 -05:00
parent fec33729f1
commit f80fe4fbc1

View File

@ -14,16 +14,9 @@ Class {
{ #category : #'instance creation' }
InstagramUrl class >> newURL: url [
| instance urlCheck |
| instance |
instance := self new.
(url includesSubstring: 'instagram.com')
ifFalse: [ UIManager default inform: '" ', url, ' " it''s not an instagram URL.'.
^ self new ].
urlCheck := url asUrl.
urlCheck hasHost ifFalse: [ urlCheck host: urlCheck segments first.
urlCheck removeFirstPathSegment. ].
urlCheck hasScheme ifFalse: [ urlCheck scheme: 'https' ].
instance url: urlCheck .
instance url: (instance urlCheck: url).
^ instance
]
@ -54,6 +47,19 @@ InstagramUrl >> url: aURL [
url := aURL
]
{ #category : #testing }
InstagramUrl >> urlCheck: aURL [
| urlCheck |
(aURL includesSubstring: 'instagram.com')
ifFalse: [ UIManager default inform: '" ', aURL, ' " it''s not an instagram URL.'.
^ self url].
urlCheck := aURL asUrl.
urlCheck hasHost ifFalse: [ urlCheck host: urlCheck segments first.
urlCheck removeFirstPathSegment. ].
urlCheck hasScheme ifFalse: [ urlCheck scheme: 'https' ].
^ urlCheck
]
{ #category : #accessing }
InstagramUrl >> urlWithoutTracking [
^ self url queryRemoveAll; asStringOrText