Skip to content

Commit

Permalink
implement function using regex instead of nxf code
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Dec 1, 2023
1 parent 0983df4 commit c552882
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
*
* @return The path that may have been resovled, as a Path.
*/

def _resolveSiblingIfNotAbsolute(str, parentPath) {
if (str !instanceof String) {
return str
}
strAsPath = file(str, hidden: true, relative: true)
if (!strAsPath.isAbsolute()) {
return parentPath.resolveSibling(str)
if (_stringIsAbsolutePath(str)) {
return parentPath.resolveSibling(str)
} else {
return file(str, hidden: true)
}
return strAsPath
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Check whether a path as a string is absolute.
*
* In the past, we tried using `file(., relative: true).isAbsolute()`,
* but the 'relative' option was added in 22.10.0.
*
* @param path The path to check, as a String.
*
* @return Whether the path is absolute, as a boolean.
*/
def _stringIsAbsolutePath(path) {
_resolve_URL_PROTOCOL = ~/^([a-zA-Z][a-zA-Z0-9]*:)?\\/.+/

assert path instanceof String
return (path =~ _resolve_URL_PROTOCOL).size() > 0
}

0 comments on commit c552882

Please sign in to comment.