@@ -110,6 +110,39 @@ github_url_rx <- function() {
110110# # output: "https://github.com/r-lib/gh"
111111github_home <- function (package = NULL ) {
112112 gh_link <- github_link(package )
113- df <- rematch2 :: re_match (gh_link , github_url_rx())
113+ df <- re_match_inline (gh_link , github_url_rx())
114114 glue(" https://github.com/{df$owner}/{df$repo}" )
115115}
116+
117+ # # inline a simplified version of rematch2::re_match()
118+ re_match_inline <- function (text , pattern ) {
119+ match <- regexpr(pattern , text , perl = TRUE )
120+ start <- as.vector(match )
121+ length <- attr(match , " match.length" )
122+ end <- start + length - 1L
123+
124+ matchstr <- substring(text , start , end )
125+ matchstr [ start == - 1 ] <- NA_character_
126+
127+ res <- data.frame (
128+ stringsAsFactors = FALSE ,
129+ .text = text ,
130+ .match = matchstr
131+ )
132+
133+ if (! is.null(attr(match , " capture.start" ))) {
134+
135+ gstart <- attr(match , " capture.start" )
136+ glength <- attr(match , " capture.length" )
137+ gend <- gstart + glength - 1L
138+
139+ groupstr <- substring(text , gstart , gend )
140+ groupstr [ gstart == - 1 ] <- NA_character_
141+ dim(groupstr ) <- dim(gstart )
142+
143+ res <- cbind(groupstr , res , stringsAsFactors = FALSE )
144+ }
145+
146+ names(res ) <- c(attr(match , " capture.names" ), " .text" , " .match" )
147+ res
148+ }
0 commit comments