Refactoring URL checking.
This commit is contained in:
parent
fec33729f1
commit
f80fe4fbc1
|
@ -14,16 +14,9 @@ Class {
|
||||||
|
|
||||||
{ #category : #'instance creation' }
|
{ #category : #'instance creation' }
|
||||||
InstagramUrl class >> newURL: url [
|
InstagramUrl class >> newURL: url [
|
||||||
| instance urlCheck |
|
| instance |
|
||||||
instance := self new.
|
instance := self new.
|
||||||
(url includesSubstring: 'instagram.com')
|
instance url: (instance urlCheck: url).
|
||||||
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
|
^ instance
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -54,6 +47,19 @@ InstagramUrl >> url: aURL [
|
||||||
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 }
|
{ #category : #accessing }
|
||||||
InstagramUrl >> urlWithoutTracking [
|
InstagramUrl >> urlWithoutTracking [
|
||||||
^ self url queryRemoveAll; asStringOrText
|
^ self url queryRemoveAll; asStringOrText
|
||||||
|
|
Loading…
Reference in New Issue