Skip to content

Commit

Permalink
Refine regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
dpino committed Oct 16, 2015
1 parent cbfd314 commit 59249e7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ function usage (status)
end

function programname (program)
return program:gsub("^.*/", ""):
gsub("-[0-9.]+$", ""):
gsub("-", "_")
return program:gsub("^.*/", "")
:gsub("-[0-9.]+[-%w]+$", "")
:gsub("-", "_")
end

function modulename (program)
Expand Down Expand Up @@ -117,6 +117,8 @@ end
function selftest ()
assert(programname("/bin/snabb-1.0") == "snabb",
"Incorrect program name parsing")
assert(programname("/bin/snabb-1.0-alpha2") == "snabb",
"Incorrect program name parsing")
assert(programname("/bin/snabb-nfv") == "snabb_nfv",
"Incorrect program name parsing")
assert(programname("/bin/snabb-nfv-1.0") == "snabb_nfv",
Expand Down

0 comments on commit 59249e7

Please sign in to comment.