From 7db9c9bb74f3d28bd49ff064e6815b14153b809e Mon Sep 17 00:00:00 2001 From: MIIIG Date: Wed, 15 Feb 2023 21:25:47 +0500 Subject: [PATCH] fix parsing when dn equal base fix bug when ending position for slice is -1 --- lib/paddle/parsing.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/paddle/parsing.ex b/lib/paddle/parsing.ex index b521657..10477c4 100644 --- a/lib/paddle/parsing.ex +++ b/lib/paddle/parsing.ex @@ -228,7 +228,11 @@ defmodule Paddle.Parsing do defp strip_base_from_dn(dn, 0) when is_binary(dn), do: dn defp strip_base_from_dn(dn, base_length) when is_binary(dn) do dn_length = String.length(dn) - String.slice(dn, 0, dn_length - base_length - 1) + slice_length = case dn_length - base_length do + 0 -> 0 + _ -> dn_length - base_length - 1 + end + String.slice(dn, 0, slice_length) end # ===================