11"use strict" ;
22const path = require ( "path" ) ;
33
4+ /**
5+ * @typedef {Object } MakeRelativePathsCache
6+ * @property {Map<string, Map<string, string>>= } relativePaths
7+ */
8+
9+ /**
10+ *
11+ * @param {string } maybeAbsolutePath path to check
12+ * @return {boolean } returns true if path is "Absolute Path"-like
13+ */
414const looksLikeAbsolutePath = maybeAbsolutePath => {
515 return / ^ (?: [ a - z ] : \\ | \/ ) / i. test ( maybeAbsolutePath ) ;
616} ;
717
18+ /**
19+ *
20+ * @param {string } p path to normalize
21+ * @return {string } normalized version of path
22+ */
823const normalizePathSeparator = p => p . replace ( / \\ / g, "/" ) ;
924
25+ /**
26+ *
27+ * @param {string } context context for relative path
28+ * @param {string } identifier identifier for path
29+ * @return {string } a converted relative path
30+ */
1031const _makePathsRelative = ( context , identifier ) => {
1132 return identifier
1233 . split ( / ( [ | ! ] ) / )
@@ -19,6 +40,13 @@ const _makePathsRelative = (context, identifier) => {
1940 . join ( "" ) ;
2041} ;
2142
43+ /**
44+ *
45+ * @param {string } context context used to create relative path
46+ * @param {string } identifier identifier used to create relative path
47+ * @param {MakeRelativePathsCache= } cache the cache object being set
48+ * @return {string } the returned relative path
49+ */
2250exports . makePathsRelative = ( context , identifier , cache ) => {
2351 if ( ! cache ) return _makePathsRelative ( context , identifier ) ;
2452
0 commit comments