Merge pull request #45 from poanetwork/vb-fix-first-pragma-experimental-detection

Fix first pragma experimental detection
This commit is contained in:
Victor Baranov 2020-08-12 07:56:15 +03:00 committed by GitHub
commit 13de1e363d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 11 deletions

View File

@ -7,18 +7,21 @@ const pragmaExperimentalstr = 'pragma experimental'
function removeDuplicatedExpHeaders(content) { function removeDuplicatedExpHeaders(content) {
//1st pragma solidity declaration //1st pragma solidity declaration
const { firstIndex, lastIndex } = getFirstPragmaExp(content) const { firstIndex, lastIndex } = getFirstPragmaExp(content)
const contentPart = content.substr(lastIndex) if (firstIndex >= 0 && lastIndex > 0) {
let contentFiltered = contentPart const contentPart = content.substr(lastIndex)
//remove other pragma solidity declarations let contentFiltered = contentPart
const regex = new RegExp(pragmaExperimentalstr,'gi') //remove other pragma solidity declarations
let result const regex = new RegExp(pragmaExperimentalstr,'gi')
while ( (result = regex.exec(contentPart)) ) { let result
const start = result.index while ( (result = regex.exec(contentPart)) ) {
const end = start + contentPart.substr(start).indexOf(SEMICOLON) + 1 const start = result.index
if (start != firstIndex) contentFiltered = contentFiltered.replace(contentPart.substring(start, end), EMPTY) const end = start + contentPart.substr(start).indexOf(SEMICOLON) + 1
if (start != firstIndex) contentFiltered = contentFiltered.replace(contentPart.substring(start, end), EMPTY)
}
return contentFiltered
} else {
return content
} }
return contentFiltered
} }
/* /*