InstagramPharo/Instagram/InstagramUrl.class.st

67 lines
1.3 KiB
Smalltalk
Raw Normal View History

"
I manage instagram URLs information.
InstagramUrl newURL: 'https://instagram.com/restOfURL'
"
Class {
#name : #InstagramUrl,
#superclass : #Object,
#instVars : [
'url'
],
#category : #Instagram
}
{ #category : #'instance creation' }
InstagramUrl class >> newURL: url [
2024-01-30 17:50:17 +00:00
| instance |
instance := self new.
2024-01-30 17:50:17 +00:00
instance url: (instance urlCheck: url).
^ instance
]
{ #category : #initialization }
InstagramUrl >> initialize [
| initial |
initial := 'https://www.instagram.com' asUrl.
super initialize.
self url: initial.
]
{ #category : #opening }
InstagramUrl >> openWithoutTracking [
WebBrowser openOn: self urlWithoutTracking
]
{ #category : #accessing }
InstagramUrl >> url [
^ url
]
{ #category : #accessing }
InstagramUrl >> url: aURL [
url := aURL
]
2024-01-30 17:50:17 +00:00
{ #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
]