Creating management for instagram urls.

This commit is contained in:
ruidajo 2024-01-30 12:08:29 -05:00
parent 18b887fbc9
commit fec33729f1
6 changed files with 94 additions and 0 deletions

3
.project Normal file
View File

@ -0,0 +1,3 @@
{
'srcDirectory' : ''
}

3
.properties Normal file
View File

@ -0,0 +1,3 @@
{
#format : #tonel
}

View File

@ -0,0 +1,26 @@
Class {
#name : #InstagramUrlTest,
#superclass : #TestCase,
#category : #'Instagram-Tests'
}
{ #category : #tests }
InstagramUrlTest >> testInstagramUrlInstanceCreation [
| i |
i := InstagramUrl newURL: 'instagram.com'.
self assert: i url asStringOrText equals: 'https://instagram.com/'
]
{ #category : #tests }
InstagramUrlTest >> testNotInstagramUrl1 [
| i |
i := InstagramUrl newURL: 'nstgrm.com'.
self assert: i url asStringOrText equals: 'https://www.instagram.com/'
]
{ #category : #tests }
InstagramUrlTest >> testNotInstagramUrl2 [
| i |
i := InstagramUrl newURL: 'nstgrm.com'.
self assert: i class equals: InstagramUrl new class.
]

View File

@ -0,0 +1 @@
Package { #name : #'Instagram-Tests' }

View File

@ -0,0 +1,60 @@
"
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 [
| instance urlCheck |
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
]
{ #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
]
{ #category : #accessing }
InstagramUrl >> urlWithoutTracking [
^ self url queryRemoveAll; asStringOrText
]

1
Instagram/package.st Normal file
View File

@ -0,0 +1 @@
Package { #name : #Instagram }