Skip to content

Commit e17b0cd

Browse files
chore: refactor code
1 parent ab06fa7 commit e17b0cd

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

script/libraries/LibInitializeGuard.sol

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -334,20 +334,12 @@ library LibInitializeGuard {
334334
}
335335

336336
function _getContractNameFromAbsolutePath(string memory path) internal pure returns (string memory contractName) {
337-
bytes memory pathBytes = bytes(path);
338-
uint256 length = pathBytes.length;
339-
bytes memory contractNameBytes = new bytes(length - 4);
340-
341-
if (
342-
length > 4 && pathBytes[length - 4] == "." && pathBytes[length - 3] == "s" && pathBytes[length - 2] == "o"
343-
&& pathBytes[length - 1] == "l"
344-
) {
345-
// Create a new bytes array without the ".sol" extension
346-
for (uint256 i = 0; i < length - 4; i++) {
347-
contractNameBytes[i] = pathBytes[i];
348-
}
337+
uint256 length = bytes(path).length;
338+
// Remove ".sol"
339+
if (path.endsWith(".sol")) {
340+
contractName = path.slice(0, length - 4);
349341
}
350-
return string(contractNameBytes);
342+
return string(contractName);
351343
}
352344

353345
/**

0 commit comments

Comments
 (0)