Skip to content

Commit 1f9477a

Browse files
authored
Merge pull request #21 from dfeyer/task-windows-support
TASK: Support Windows
2 parents 3f1e537 + 3bb2741 commit 1f9477a

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Build your own
1919
# Get the dependecies
2020
go get
2121
# Build
22-
go Build
22+
go build
2323

2424
Run the proxy
2525
-------------

flowpathmapper/flowpathmapper.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"regexp"
1919
"strconv"
2020
"strings"
21+
"runtime"
2122
)
2223

2324
const (
@@ -28,7 +29,8 @@ const (
2829

2930
var (
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
4352
type 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

105117
func (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

Comments
 (0)