Creating management for instagram urls.
This commit is contained in:
parent
18b887fbc9
commit
fec33729f1
3
.properties
Normal file
3
.properties
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
#format : #tonel
|
||||
}
|
26
Instagram-Tests/InstagramUrlTest.class.st
Normal file
26
Instagram-Tests/InstagramUrlTest.class.st
Normal 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.
|
||||
]
|
1
Instagram-Tests/package.st
Normal file
1
Instagram-Tests/package.st
Normal file
@ -0,0 +1 @@
|
||||
Package { #name : #'Instagram-Tests' }
|
60
Instagram/InstagramUrl.class.st
Normal file
60
Instagram/InstagramUrl.class.st
Normal 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
1
Instagram/package.st
Normal file
@ -0,0 +1 @@
|
||||
Package { #name : #Instagram }
|
Loading…
Reference in New Issue
Block a user