Add namespace and some documentation
diff --git a/R/KorAPConnection.R b/R/KorAPConnection.R
index 1fdc587..469f228 100644
--- a/R/KorAPConnection.R
+++ b/R/KorAPConnection.R
@@ -1,11 +1,21 @@
#' @import jsonlite
#' @import curl
-library(jsonlite)
-
defaultKorAPUrl <- "https://korap.ids-mannheim.de/"
-KorAPConnection <- function(KorAPUrl=defaultKorAPUrl, apiVersion='v1.0', apiUrl = paste0(KorAPUrl, 'api/' ,apiVersion, '/')) {
+#' \code{KorAPQuery} initiates a connect to some KorAP server.
+#' @param KorAPUrl instead of providing the query and vc string parameters, you can also simply copy a KorAP query URL from your browser and use it here (and in \code{KorAPConnection}) to provide all necessary information for the query.
+#' @return object that contains all necessary connection information and can be used on \code{\link{KorAPQuery}}
+#' @export
+KorAPConnection <- function(KorAPUrl=defaultKorAPUrl, apiVersion='v1.0', apiUrl = NA) {
+ m <-regexpr("https?://[^?]+", KorAPUrl, perl = TRUE)
+ KorAPUrl <- regmatches(KorAPUrl, m)
+ if (!endsWith(KorAPUrl, '/')) {
+ KorAPUrl <- paste0(KorAPUrl, "/")
+ }
+ if (is.na(apiUrl)) {
+ apiUrl = paste0(KorAPUrl, 'api/', apiVersion, '/')
+ }
con <- data.frame(apiUrl, KorAPUrl, apiVersion)
return(con)
}