InstagramPharo/Instagram/InstagramUrl.class.st

68 lines
1.3 KiB
Smalltalk
Raw Normal View History

"
I manage instagram URLs information.
InstagramUrl newURL: 'https://instagram.com/restOfURL'
"
Class {
2024-05-26 18:44:40 +00:00
#name : 'InstagramUrl',
#superclass : 'Object',
#instVars : [
'url'
],
2024-05-26 18:44:40 +00:00
#category : 'Instagram',
#package : 'Instagram'
}
2024-05-26 18:44:40 +00:00
{ #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
]
2024-05-26 18:44:40 +00:00
{ #category : 'initialization' }
InstagramUrl >> initialize [
| initial |
initial := 'https://www.instagram.com' asUrl.
super initialize.
self url: initial.
]
2024-05-26 18:44:40 +00:00
{ #category : 'opening' }
InstagramUrl >> openWithoutTracking [
WebBrowser openOn: self urlWithoutTracking
]
2024-05-26 18:44:40 +00:00
{ #category : 'accessing' }
InstagramUrl >> url [
^ url
]
2024-05-26 18:44:40 +00:00
{ #category : 'accessing' }
InstagramUrl >> url: aURL [
url := aURL
]
2024-05-26 18:44:40 +00:00
{ #category : 'testing' }
InstagramUrl >> urlCheck: aURLString [
2024-01-30 17:50:17 +00:00
| urlCheck |
2024-05-26 18:44:40 +00:00
(aURLString includesSubstring: 'instagram.com')
ifFalse: [ UIManager default inform: '" ', aURLString, ' " it''s not an instagram URL.'.
2024-01-30 17:50:17 +00:00
^ self url].
2024-05-26 18:44:40 +00:00
urlCheck := aURLString asUrl.
2024-01-30 17:50:17 +00:00
urlCheck hasHost ifFalse: [ urlCheck host: urlCheck segments first.
urlCheck removeFirstPathSegment. ].
urlCheck hasScheme ifFalse: [ urlCheck scheme: 'https' ].
^ urlCheck
]
2024-05-26 18:44:40 +00:00
{ #category : 'accessing' }
InstagramUrl >> urlWithoutTracking [
^ self url queryRemoveAll; asStringOrText
]