@@ -184,6 +184,7 @@ contract VanityURL is Ownable,Pausable {
184
184
6. Update the mapping variables
185
185
*/
186
186
function reserve (string _vanity_url ) whenNotPaused public {
187
+ _vanity_url = _toLower (_vanity_url);
187
188
require (checkForValidity (_vanity_url));
188
189
require (vanity_address_mapping[_vanity_url] == address (0x0 ));
189
190
require (bytes (address_vanity_mapping[msg .sender ]).length == 0 );
@@ -193,6 +194,25 @@ contract VanityURL is Ownable,Pausable {
193
194
address_vanity_mapping[msg .sender ] = _vanity_url;
194
195
}
195
196
197
+ /*
198
+ function to make lowercase
199
+ */
200
+
201
+ function _toLower (string str ) internal returns (string ) {
202
+ bytes memory bStr = bytes (str);
203
+ bytes memory bLower = new bytes (bStr.length );
204
+ for (uint i = 0 ; i < bStr.length ; i++ ) {
205
+ // Uppercase character...
206
+ if ((bStr[i] >= 65 ) && (bStr[i] <= 90 )) {
207
+ // So we add 32 to make it lowercase
208
+ bLower[i] = bytes1 (int (bStr[i]) + 32 );
209
+ } else {
210
+ bLower[i] = bStr[i];
211
+ }
212
+ }
213
+ return string (bLower);
214
+ }
215
+
196
216
/*
197
217
function to verify vanityURL
198
218
1. Minimum length 4
@@ -221,6 +241,7 @@ contract VanityURL is Ownable,Pausable {
221
241
222
242
function changeVanityURL (string _vanity_url ) whenNotPaused public {
223
243
require (bytes (address_vanity_mapping[msg .sender ]).length != 0 );
244
+ _vanity_url = _toLower (_vanity_url);
224
245
require (checkForValidity (_vanity_url));
225
246
require (vanity_address_mapping[_vanity_url] == address (0x0 ));
226
247
require (reservedKeywords[_vanity_url] != 1 );
0 commit comments