Sanitizing urls. (see http://mutabit.com/repos.fossil/grafoscopio/tktview?name=c7fe88f9ca ).
This commit is contained in:
parent
5af923bb89
commit
830cdedbc8
@ -11,8 +11,8 @@ Class {
|
||||
{ #category : #'graphical interface' }
|
||||
GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into: location [
|
||||
| fileName |
|
||||
fileName := (downloadUrl splitOn: $/) last.
|
||||
(location / fileName) exists ifTrue: [ (location / fileName) ensureDelete ].
|
||||
fileName := downloadUrl segments last.
|
||||
(location / fileName) ensureDelete.
|
||||
[: bar |
|
||||
bar title: aString.
|
||||
[ZnClient new
|
||||
@ -27,3 +27,26 @@ GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into
|
||||
progress resume ].
|
||||
] asJob run.
|
||||
]
|
||||
|
||||
{ #category : #private }
|
||||
GrafoscopioUtils class >> sanitize: url [
|
||||
"I remove white spaces in url's and prepend 'http://' to urls when it is ommited, so
|
||||
operations that rely on sane and well formed urls don't throw error messages."
|
||||
| sanitized modUrl |
|
||||
modUrl := url.
|
||||
[modUrl endsWith: ' ']
|
||||
whileTrue: [ modUrl := modUrl copyFrom: 1 to: (modUrl size - 1) ].
|
||||
(url beginsWith: 'http://')
|
||||
ifFalse: [ sanitized := ('http://', modUrl) asUrl ]
|
||||
ifTrue: [ sanitized := modUrl asUrl ].
|
||||
^ sanitized
|
||||
]
|
||||
|
||||
{ #category : #updating }
|
||||
GrafoscopioUtils class >> update [
|
||||
"Updates GrafoscopioUtils with new versions of itself take from the source code repository."
|
||||
Gofer new
|
||||
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
|
||||
package: 'GrafoscopioUtils';
|
||||
load.
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user