Skip to content

Commit 440cda6

Browse files
authored
Merge pull request #7 from SpringRole/lower-case
added lowercase function
2 parents 3bb10c0 + 0cd31b1 commit 440cda6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Vanity.sol

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ contract VanityURL is Ownable,Pausable {
184184
6. Update the mapping variables
185185
*/
186186
function reserve(string _vanity_url) whenNotPaused public {
187+
_vanity_url = _toLower(_vanity_url);
187188
require(checkForValidity(_vanity_url));
188189
require(vanity_address_mapping[_vanity_url] == address(0x0));
189190
require(bytes(address_vanity_mapping[msg.sender]).length == 0);
@@ -193,6 +194,25 @@ contract VanityURL is Ownable,Pausable {
193194
address_vanity_mapping[msg.sender] = _vanity_url;
194195
}
195196

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+
196216
/*
197217
function to verify vanityURL
198218
1. Minimum length 4
@@ -221,6 +241,7 @@ contract VanityURL is Ownable,Pausable {
221241

222242
function changeVanityURL(string _vanity_url) whenNotPaused public {
223243
require(bytes(address_vanity_mapping[msg.sender]).length != 0);
244+
_vanity_url = _toLower(_vanity_url);
224245
require(checkForValidity(_vanity_url));
225246
require(vanity_address_mapping[_vanity_url] == address(0x0));
226247
require(reservedKeywords[_vanity_url] != 1);

0 commit comments

Comments
 (0)