diff --git a/stdlib/http/src/main/java/org/ballerinalang/net/http/HttpDispatcher.java b/stdlib/http/src/main/java/org/ballerinalang/net/http/HttpDispatcher.java index 656622242b38..60abbb114b17 100644 --- a/stdlib/http/src/main/java/org/ballerinalang/net/http/HttpDispatcher.java +++ b/stdlib/http/src/main/java/org/ballerinalang/net/http/HttpDispatcher.java @@ -34,6 +34,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.net.URI; import java.net.URLDecoder; import java.util.HashMap; import java.util.List; @@ -108,6 +109,16 @@ private static void setInboundReqProperties(HttpCarbonMessage inboundReqMsg, Str inboundReqMsg.setProperty(HttpConstants.RAW_QUERY_STR, rawQuery); } + public static URI getValidatedURI(String uriStr) { + URI requestUri; + try { + requestUri = URI.create(uriStr); + } catch (IllegalArgumentException e) { + throw new BallerinaConnectorException(e.getMessage()); + } + return requestUri; + } + /** * This method finds the matching resource for the incoming request. *