From cc66180ad830febc3fdfba7fa04574806f65e77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Thu, 16 Apr 2020 09:52:58 +0200 Subject: [PATCH 1/2] Ensure path relativeTo() is nothrow. --- source/vibe/core/path.d | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/vibe/core/path.d b/source/vibe/core/path.d index 1c4acad..b3aa794 100644 --- a/source/vibe/core/path.d +++ b/source/vibe/core/path.d @@ -67,7 +67,7 @@ Path relativeTo(Path)(Path path, Path base_path) @safe enum up = Path.Segment2("..", Path.defaultSeparator); auto ret = Path(base_nodes.map!(p => up).chain(nodes)); if (path.endsWithSlash) { - if (ret.empty) return Path("." ~ path.toString()[$-1]); + if (ret.empty) return Path.fromTrustedString("." ~ path.toString()[$-1]); else ret.endsWithSlash = true; } return ret; @@ -142,6 +142,12 @@ unittest { } } +nothrow unittest { + auto p1 = PosixPath.fromTrustedString("/foo/bar/baz"); + auto p2 = PosixPath.fromTrustedString("/foo/baz/bam"); + assert(p2.relativeTo(p1).toString == "../../baz/bam"); +} + /** Computes the relative path to this path from `base_path` using web path rules. From f8c25adf02a5ce024769c6aad7fef83093149bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Thu, 16 Apr 2020 09:53:13 +0200 Subject: [PATCH 2/2] Ensure that HashMap with POD types is nothrow. --- source/vibe/internal/hashmap.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/vibe/internal/hashmap.d b/source/vibe/internal/hashmap.d index 4a09df8..d803eb6 100644 --- a/source/vibe/internal/hashmap.d +++ b/source/vibe/internal/hashmap.d @@ -250,7 +250,7 @@ struct HashMap(TKey, TValue, Traits = DefaultHashMapTraits!TKey) } } -unittest { +nothrow unittest { import std.conv; HashMap!(string, string) map;