diff --git a/org/cfstatic/CfStatic.cfc b/org/cfstatic/CfStatic.cfc index 4fa5696..8550d17 100755 --- a/org/cfstatic/CfStatic.cfc +++ b/org/cfstatic/CfStatic.cfc @@ -115,6 +115,33 @@ + + + + + + + + var include = _appendFileTypesToSpecialIncludes( resource ); + + if ( arguments.throwOnMissing and not _resourceExists( arguments.resource ) ) { + $throw( type="cfstatic.missing.include", message="CfStatic include() error: The requested include, [#arguments.resource#], does not exist." ); + } + + renderCache = _getRenderedIncludeCache( type, debugMode )._urls; + + if ( StructKeyExists( renderCache, resource ) ) { + return renderCache[ resource ]; + } + + if ( throwOnMissing ) { + $throw( type="cfstatic.missing.include", message="CfStatic getIncludeUrl() error: The requested include, [#arguments.resource#], does not exist." ); + } + + return ""; + + + @@ -990,6 +1017,11 @@ _renderedIncludeCache.css['_ordered'] = ArrayNew(1); _renderedIncludeCache.debug.js['_ordered'] = ArrayNew(1); _renderedIncludeCache.debug.css['_ordered'] = ArrayNew(1); + + _renderedIncludeCache.js['_urls'] = StructNew(); + _renderedIncludeCache.css['_urls'] = StructNew(); + _renderedIncludeCache.debug.js['_urls'] = StructNew(); + _renderedIncludeCache.debug.css['_urls'] = StructNew(); @@ -1007,8 +1039,9 @@ node = _renderedIncludeCache[ type ]; } - ArrayAppend( node['_ordered'], rendered ); + ArrayAppend( node[ '_ordered' ], rendered ); node[ path ] = ArrayLen( node['_ordered'] ); + node[ '_urls' ][ path ] = $extractUrlFromRenderedInclude( rendered ); diff --git a/org/cfstatic/util/Base.cfc b/org/cfstatic/util/Base.cfc index f2269b7..e905994 100644 --- a/org/cfstatic/util/Base.cfc +++ b/org/cfstatic/util/Base.cfc @@ -182,6 +182,21 @@ ', ieConditional ) & $newline() /> + + + + + var regex = '^.*?(href|src)="(.*?)".*$'; + var replaced = ReReplaceNoCase( renderedInclude, regex, "\2" ); + + if ( replaced == renderedInclude ) { + return ""; + } + + return replaced; + + + diff --git a/tests/integration/org/cfstatic/CfStaticTest.cfc b/tests/integration/org/cfstatic/CfStaticTest.cfc index a18df80..9d627be 100644 --- a/tests/integration/org/cfstatic/CfStaticTest.cfc +++ b/tests/integration/org/cfstatic/CfStaticTest.cfc @@ -1067,8 +1067,9 @@ var expected = "/mystaticurl/min/someFolder.min.css"; - rootDir &= 'goodFiles/standardFolders/'; + var actual = ""; + rootDir &= 'goodFiles/standardFolders/'; cfstatic.init( staticDirectory = rootDir @@ -1076,7 +1077,10 @@ , debugKey = "doNotLetMxUnitDebugScrewTests" ); - super.assertEquals( expected, cfstatic.getIncludeUrl( "/css/someFolder/" ) ); + actual = cfstatic.getIncludeUrl( "css", "/someFolder/" ); + actual = _removeCheckSumFromFileNames( actual ); + + super.assertEquals( expected, actual );