File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 11"use strict" ;
22const path = require ( "path" ) ;
33
4+ /** @typedef {{relativePaths: Map<string, string|Map<string,string>>} } MakeRelativePathsCache */
5+
6+ /**
7+ *
8+ * @param {string } maybeAbsolutePath path to check
9+ * @return {boolean } returns true if path is "Absolute Path"-like
10+ */
411const looksLikeAbsolutePath = maybeAbsolutePath => {
512 return / ^ (?: [ a - z ] : \\ | \/ ) / i. test ( maybeAbsolutePath ) ;
613} ;
714
15+ /**
16+ *
17+ * @param {string } p path to normalize
18+ * @return {string } normalized version of path
19+ */
820const normalizePathSeparator = p => p . replace ( / \\ / g, "/" ) ;
921
22+ /**
23+ *
24+ * @param {string } context context for relative path
25+ * @param {string } identifier identifier for path
26+ * @return {string } a converted relative path
27+ */
1028const _makePathsRelative = ( context , identifier ) => {
1129 return identifier
1230 . split ( / ( [ | ! ] ) / )
@@ -19,6 +37,13 @@ const _makePathsRelative = (context, identifier) => {
1937 . join ( "" ) ;
2038} ;
2139
40+ /**
41+ *
42+ * @param {string } context context used to create relative path
43+ * @param {string } identifier identifier used to create relative path
44+ * @param {MakeRelativePathsCache= } cache the cache object being set
45+ * @return {string } the returned relative path
46+ */
2247exports . makePathsRelative = ( context , identifier , cache ) => {
2348 if ( ! cache ) return _makePathsRelative ( context , identifier ) ;
2449
You can’t perform that action at this time.
0 commit comments