@@ -28,7 +28,7 @@ const {
28
28
const path = require ( 'path' ) ;
29
29
const fs = require ( 'fs' ) ;
30
30
31
- const rootDir = path . dirname ( __dirname ) ;
31
+ const rootDir = path . posix . dirname ( __dirname ) ;
32
32
33
33
// A simple regex to capture all links which are not images.
34
34
const linkFinder = / (?< ! ! ) (?< description > \[ [ ^ \] ] * \] (? = \( (?< target > [ ^ ) ] * ) \) | \[ [ ^ \] ] * \] ) ) / g;
@@ -67,7 +67,7 @@ const getRenamedFileMapping = (renames) => {
67
67
* @param {string } file The file to normalise the location of
68
68
* @returns {string } The normalised location
69
69
*/
70
- const getNormalisedFile = ( file ) => `/${ path . relative ( rootDir , file ) } ` ;
70
+ const getNormalisedFile = ( file ) => `/${ path . posix . relative ( rootDir , file ) } ` ;
71
71
72
72
/**
73
73
* Get an absolute link relative to the root directory of the project.
@@ -86,10 +86,10 @@ const getNormalisedLink = (file, link) => {
86
86
const normalisedFile = getNormalisedFile ( file ) ;
87
87
88
88
// Get the directory that it is in.
89
- const normalisedDir = path . dirname ( normalisedFile ) ;
89
+ const normalisedDir = path . posix . dirname ( normalisedFile ) ;
90
90
91
91
// Return a link relative to the file that the link was found in.
92
- return path . join ( normalisedDir , link ) ;
92
+ return path . posix . join ( normalisedDir , link ) ;
93
93
} ;
94
94
95
95
/**
@@ -152,7 +152,7 @@ const findFile = (file) => {
152
152
] ;
153
153
154
154
for ( const filePath of paths ) {
155
- const fullPath = path . join ( rootDir , filePath ) ;
155
+ const fullPath = path . posix . join ( rootDir , filePath ) ;
156
156
try {
157
157
// Allow use of fs.statSync here because it's preferable to asynchronous rule handling for markdownlint.
158
158
// eslint-disable-next-line no-restricted-properties
@@ -190,7 +190,7 @@ const getOptimisedLink = (mappings, file, currentLink, forceRelative) => {
190
190
// Either the link has changed, or the forceRelative configuration is set.
191
191
// Update to point to a relative _file_ if possible.
192
192
const updatedFileLink = findFile ( updatedLink ) ;
193
- let relativeLink = path . relative ( path . dirname ( normalisedCurrentFile ) , updatedFileLink ) ;
193
+ let relativeLink = path . posix . relative ( path . posix . dirname ( normalisedCurrentFile ) , updatedFileLink ) ;
194
194
195
195
if ( relativeLink . length === 0 ) {
196
196
// This is a link to the current document.
0 commit comments