Skip to content

Commit

Permalink
Remove last empty line from password and uuid generator (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joaolfelicio authored Feb 20, 2025
1 parent ab94a84 commit 03509c8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ private void OnGenerateButtonClick()

// Generate a random password using the the combined character set.
var newPasswords = new StringBuilder();
for (int i = 0; i < _settingsProvider.GetSetting(passwordsToGenerate); i++)

int passwordsCount = _settingsProvider.GetSetting(passwordsToGenerate);

for (int i = 0; i < passwordsCount; i++)
{
string password
= PasswordGeneratorHelper.GeneratePassword(
Expand All @@ -285,10 +288,19 @@ string password
hasSpecialCharacters,
excludedCharactersList);

if (password.Length > 0)
if (password.Length == 0)
{
continue;
}

if (i != passwordsCount - 1)
{
newPasswords.AppendLine(password);
}
else
{
newPasswords.Append(password);
}
}

_outputText.Text(newPasswords.ToString());
Expand Down
13 changes: 11 additions & 2 deletions src/DevToys.Tools/Tools/Generators/UUID/UUIDGeneratorGuidTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,24 @@ private void OnGenerateButtonClick()
{
var newGuids = new StringBuilder();

for (int i = 0; i < Math.Max(_settingsProvider.GetSetting(uuidToGenerate), 1); i++)
int guidsCount = Math.Max(_settingsProvider.GetSetting(uuidToGenerate), 1);

for (int i = 0; i < guidsCount; i++)
{
string newUuid
= UuidHelper.GenerateUuid(
_settingsProvider.GetSetting(version),
_settingsProvider.GetSetting(hyphens),
_settingsProvider.GetSetting(uppercase));

newGuids.AppendLine(newUuid);
if (i != guidsCount - 1)
{
newGuids.AppendLine(newUuid);
}
else
{
newGuids.Append(newUuid);
}
}

_outputText.Text(newGuids.ToString());
Expand Down

0 comments on commit 03509c8

Please sign in to comment.