fix bug where slice was called on undefined

If a variable was matched but no data existed to replace the variable then slice would be called on undefined. It assumes that a default must exist. This was breaking the test "should be able to replace an environment var with underscores" for me as I did not have the environment variable used in the test.

This fix will check to see if a default was provided before calling slice on the default match.