Skip to content

Commit 81d1750

Browse files
authored
Add support for sub contexts
Adds support for path mapping while using sub context. `./flow-debugproxy -c "Development/Local"`
1 parent dea23f4 commit 81d1750

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

flowpathmapper/flowpathmapper.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const (
2828

2929
var (
3030
regexpPhpFile = regexp.MustCompile(`(?://)?(/[^ ]*\.php)`)
31-
regexpFilename = regexp.MustCompile(`filename=["]?file://(\S+)/Data/Temporary/[^/]*/Cache/Code/Flow_Object_Classes/([^"]*)\.php`)
31+
regexpFilename = regexp.MustCompile(`filename=["]?file://(\S+)/Data/Temporary/([^/]*(/SubContext[^/]*)?)/Cache/Code/Flow_Object_Classes/([^"]*)\.php`)
3232
regexpPathAndFilename = regexp.MustCompile(`(?m)^# PathAndFilename: (.*)$`)
3333
regexpPackageClass = regexp.MustCompile(`(.*?)/Packages/[^/]*/(.*?)/Classes/(.*).php`)
3434
regexpDot = regexp.MustCompile(`[\./]`)
@@ -92,14 +92,15 @@ func (p *PathMapper) doTextPathMapping(message []byte) []byte {
9292

9393
func (p *PathMapper) getCachePath(base, filename string) string {
9494
cachePath := strings.Replace(cachePathPattern, "@base@", base, 1)
95-
cachePath = strings.Replace(cachePath, "@context@", p.config.Context, 1)
95+
contextPath := strings.Replace(p.config.Context, "/", "/SubContext", 1)
96+
cachePath = strings.Replace(cachePath, "@context@", contextPath, 1)
9697
return strings.Replace(cachePath, "@filename@", filename, 1)
9798
}
9899

99100
func (p *PathMapper) doXMLPathMapping(b []byte) []byte {
100101
var processedMapping = map[string]string{}
101102
for _, match := range regexpFilename.FindAllStringSubmatch(string(b), -1) {
102-
path := p.getCachePath(match[1], match[2])
103+
path := p.getCachePath(match[1], match[4])
103104
if _, ok := processedMapping[path]; ok == false {
104105
if originalPath, exist := p.pathMapping.Get(path); exist {
105106
if p.config.VeryVerbose {

0 commit comments

Comments
 (0)