Merge pull request #2150 from ethereum/regex

don't use look behinds
pull/2159/head^2
Rob 3 years ago committed by GitHub
commit 881188ffd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      libs/remix-ui/search/src/lib/context/context.tsx

@ -202,18 +202,28 @@ export const SearchProvider = ({
}
}, [])
//*.sol, **/*.txt, contracts/*
const setGlobalExpression = (paths: string) => {
const results = []
paths.split(',').forEach(path => {
path = path.trim()
if(path.startsWith('*.')) path = path.replace(/(\*\.)/g, '**/*.')
if(path.endsWith('/*') && !path.endsWith('/**/*')) path = path.replace(/(\*)/g, '**/*.*')
results.push(path)
})
return results
}
useEffect(() => {
if (state.find) {
(async () => {
const files = await getDirectory('/', plugin)
const pathFilter: any = {}
if (state.include){
const includeWithGlobalExpression = state.include.replaceAll(/(?<!\/)(\*\.)/g, '**/*.')
pathFilter.include = includeWithGlobalExpression.split(',').map(i => i.trim())
pathFilter.include = setGlobalExpression(state.include)
}
if (state.exclude){
const excludeWithGlobalExpression = state.exclude.replaceAll(/(?<!\/)(\*\.)/g, '**/*.')
pathFilter.exclude = excludeWithGlobalExpression.split(',').map(i => i.trim())
pathFilter.exclude = setGlobalExpression(state.exclude)
}
const filteredFiles = files.filter(filePathFilter(pathFilter)).map(file => {
const r: SearchResult = {

Loading…
Cancel
Save