import path from "path" ; import LocationUtils from "../../utils/location" ; import fileToOutput from "./fileToOutput" ; param { Output } output param { string } filePath return { string } function fileToURL ( output , filePath ) { const options = output . getOptions ( ) ; const directoryIndex = options . get ( "directoryIndex" ) ; filePath = fileToOutput ( output , filePath ) ; if ( directoryIndex && path . basename ( filePath ) == "index.html" ) { filePath = `${ path . dirname ( filePath ) }/` ; } return LocationUtils . normalize ( filePath ) ; } export default fileToURL ;