Slim down buildWebUIRequestUrl function

Change-Id: I3da8e74388fc5a703bd83895cae6dea3741d4f59
diff --git a/R/KorAPQuery.R b/R/KorAPQuery.R
index c1c29d9..fb6af8b 100644
--- a/R/KorAPQuery.R
+++ b/R/KorAPQuery.R
@@ -427,11 +427,37 @@
       ci(conf.level = conf.level)
 })
 
+#' buildWebUIRequestUrlFromString
+#'
+#' @rdname KorAPQuery-class
+#' @importFrom urltools url_encode
+#' @export
+buildWebUIRequestUrlFromString <- function(KorAPUrl,
+                                 query,
+                                 vc = "",
+                                 ql = "poliqarp"
+) {
+  if ("KorAPConnection" %in% class(KorAPUrl)) {
+    KorAPUrl <- KorAPUrl@KorAPUrl
+  }
+
+  request <-
+    paste0(
+      '?q=',
+      urltools::url_encode(enc2utf8(as.character(query))),
+      ifelse(vc != '',
+             paste0('&cq=', urltools::url_encode(enc2utf8(vc))),
+             ''),
+      '&ql=',
+      ql
+    )
+  paste0(KorAPUrl, request)
+}
 
 #' buildWebUIRequestUrl
 #'
 #' @rdname KorAPQuery-class
-#' @importFrom urltools url_encode
+#' @importFrom httr parse_url
 #' @export
 buildWebUIRequestUrl <- function(kco,
                                  query = if (missing(KorAPUrl))
@@ -440,42 +466,9 @@
                                    httr::parse_url(KorAPUrl)$query$q,
                                  vc = if (missing(KorAPUrl)) "" else httr::parse_url(KorAPUrl)$query$cq,
                                  KorAPUrl,
-                                 metadataOnly = TRUE,
-                                 ql = if (missing(KorAPUrl)) "poliqarp" else httr::parse_url(KorAPUrl)$query$ql,
-                                 fields = c(
-                                   "corpusSigle",
-                                   "textSigle",
-                                   "pubDate",
-                                   "pubPlace",
-                                   "availability",
-                                   "textClass",
-                                   "snippet",
-                                   "tokens"
-                                 ),
-                                 accessRewriteFatal = TRUE) {
-  request <-
-    paste0(
-      '?q=',
-      urltools::url_encode(enc2utf8(as.character(query))),
-      ifelse(vc != '',
-        paste0('&cq=', urltools::url_encode(enc2utf8(vc))),
-        ''),
-      '&ql=',
-      ql
-    )
-  webUIRequestUrl <- paste0(kco@KorAPUrl, request)
-  requestUrl <- paste0(
-    kco@apiUrl,
-    'search',
-    request,
-    '&fields=',
-    paste(fields, collapse = ","),
-    if (metadataOnly)
-      '&access-rewrite-disabled=true'
-    else
-      ''
-  )
-  webUIRequestUrl
+                                 ql = if (missing(KorAPUrl)) "poliqarp" else httr::parse_url(KorAPUrl)$query$ql) {
+
+  buildWebUIRequestUrlFromString(kco@KorAPUrl, query, vc, ql)
 }
 
 #´ format()