Merge pull request #68 from wilzbach/fix-deprecations
Fix deprecations: remove the old std.string.removechars
This commit is contained in:
commit
fd5b9db100
|
@ -540,21 +540,21 @@ unittest
|
||||||
/// Construct a binary (base64) _node.
|
/// Construct a binary (base64) _node.
|
||||||
ubyte[] constructBinary(ref Node node)
|
ubyte[] constructBinary(ref Node node)
|
||||||
{
|
{
|
||||||
|
import std.ascii : newline;
|
||||||
|
import std.array : array;
|
||||||
|
|
||||||
string value = node.as!string;
|
string value = node.as!string;
|
||||||
// For an unknown reason, this must be nested to work (compiler bug?).
|
// For an unknown reason, this must be nested to work (compiler bug?).
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
try{return Base64.decode(value.removechars("\n"));}
|
return Base64.decode(value.representation.filter!(c => !newline.canFind(c)).array);
|
||||||
catch(Exception e)
|
}
|
||||||
{
|
catch(Base64Exception e)
|
||||||
throw new Exception("Unable to decode base64 value: " ~ e.msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(UTFException e)
|
|
||||||
{
|
{
|
||||||
throw new Exception("Unable to decode base64 value: " ~ e.msg);
|
throw new Exception("Unable to decode base64 value: " ~ e.msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
ubyte[] test = cast(ubyte[])"The Answer: 42";
|
ubyte[] test = cast(ubyte[])"The Answer: 42";
|
||||||
|
@ -564,6 +564,7 @@ unittest
|
||||||
auto node = Node(input);
|
auto node = Node(input);
|
||||||
auto value = constructBinary(node);
|
auto value = constructBinary(node);
|
||||||
assert(value == test);
|
assert(value == test);
|
||||||
|
assert(value == [84, 104, 101, 32, 65, 110, 115, 119, 101, 114, 58, 32, 52, 50]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a timestamp (SysTime) _node.
|
/// Construct a timestamp (SysTime) _node.
|
||||||
|
|
Loading…
Reference in a new issue