From 1f4334d9c27a9e8144bc29c2d723447cdd64b0b1 Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:18:05 +0000 Subject: [PATCH] add %||% operator definition --- R/utils_url.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/R/utils_url.R b/R/utils_url.R index c8451b9..aa28ad8 100644 --- a/R/utils_url.R +++ b/R/utils_url.R @@ -9,3 +9,12 @@ trim_url <- function(url) { trim_trailing_slash <- function(url) { sub(pattern = "/$", replacement = "", x = url, perl = TRUE) } + +`%||%` <- function(x, y) { + if (is_null(x)) y else x +} + +# Reexport from base on newer versions of R +if (exists("%||%", envir = .BaseNamespaceEnv)) { + `%||%` <- get("%||%", envir = .BaseNamespaceEnv) +}