@@ -18,6 +18,7 @@ import (
1818 "regexp"
1919 "strconv"
2020 "strings"
21+ "runtime"
2122)
2223
2324const (
@@ -28,7 +29,8 @@ const (
2829
2930var (
3031 regexpPhpFile = regexp .MustCompile (`(?://)?(/[^ ]*\.php)` )
31- regexpFilename = regexp .MustCompile (`filename=["]?file://(\S+)/Data/Temporary/.+?/Cache/Code/Flow_Object_Classes/([^"]*)\.php` )
32+ regexpFilename__Win = regexp .MustCompile (`filename=["]?file:///(\S+)/Data/Temporary/.+?/Cache/Code/Flow_Object_Classes/([^"]*)\.php` )
33+ regexpFilename__Unix = regexp .MustCompile (`filename=["]?file://(\S+)/Data/Temporary/.+?/Cache/Code/Flow_Object_Classes/([^"]*)\.php` )
3234 regexpPathAndFilename = regexp .MustCompile (`(?m)^# PathAndFilename: (.*)$` )
3335 regexpPackageClass = regexp .MustCompile (`(.*?)/Packages/[^/]*/(.*?)/Classes/(.*).php` )
3436 regexpDot = regexp .MustCompile (`[\./]` )
@@ -39,6 +41,13 @@ func init() {
3941 pathmapperfactory .Register (framework , p )
4042}
4143
44+ func regexpFilename () * regexp.Regexp {
45+ if runtime .GOOS == "windows" {
46+ return regexpFilename__Win
47+ }
48+ return regexpFilename__Unix
49+ }
50+
4251// PathMapper handle the mapping between real code and proxy
4352type PathMapper struct {
4453 config * config.Config
@@ -78,6 +87,9 @@ func (p *PathMapper) doTextPathMapping(message []byte) []byte {
7887 var processedMapping = map [string ]string {}
7988 for _ , match := range regexpPhpFile .FindAllStringSubmatch (string (message ), - 1 ) {
8089 originalPath := match [1 ]
90+ if runtime .GOOS == "windows" {
91+ originalPath = strings .Replace (originalPath ,"//" ,"" , 1 )
92+ }
8193 path := p .mapPath (originalPath )
8294 p .logger .Debug ("doTextPathMapping %s >>> %s" , path , originalPath )
8395 processedMapping [path ] = originalPath
@@ -104,7 +116,7 @@ func (p *PathMapper) getCachePath(base, filename string) string {
104116
105117func (p * PathMapper ) doXMLPathMapping (b []byte ) []byte {
106118 var processedMapping = map [string ]string {}
107- for _ , match := range regexpFilename .FindAllStringSubmatch (string (b ), - 1 ) {
119+ for _ , match := range regexpFilename () .FindAllStringSubmatch (string (b ), - 1 ) {
108120 path := p .getCachePath (match [1 ], match [2 ])
109121 if _ , ok := processedMapping [path ]; ok == false {
110122 if originalPath , exist := p .pathMapping .Get (path ); exist {
0 commit comments