Changeset 53 in code
- Timestamp:
- Nov 29, 2016, 11:11:00 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/morty.go
r52 r53 656 656 // some web pages describe the whole link https://same:auth@same.host/same.path?same.query#new.fragment 657 657 if u.Scheme == rc.BaseURL.Scheme && 658 ( (u.User == nil && rc.BaseURL.User == nil) || (u.User.String() == rc.BaseURL.User.String())) &&658 (rc.BaseURL.User == nil || (u.User != nil && u.User.String() == rc.BaseURL.User.String())) && 659 659 u.Host == rc.BaseURL.Host && 660 660 u.Path == rc.BaseURL.Path && -
trunk/morty_test.go
r22 r53 11 11 AttrValue []byte 12 12 ExpectedOutput []byte 13 } 14 15 type StringTestCase struct { 16 Input string 17 ExpectedOutput string 13 18 } 14 19 … … 36 41 } 37 42 43 var urlTestData []*StringTestCase = []*StringTestCase{ 44 &StringTestCase{ 45 "http://x.com/", 46 "./?mortyurl=http%3A%2F%2Fx.com%2F", 47 }, 48 &StringTestCase{ 49 "http://a@x.com/", 50 "./?mortyurl=http%3A%2F%2Fa%40x.com%2F", 51 }, 52 } 53 38 54 func TestAttrSanitizer(t *testing.T) { 39 55 u, _ := url.Parse("http://127.0.0.1/") … … 45 61 if !bytes.Equal(res, testCase.ExpectedOutput) { 46 62 t.Errorf( 47 `Attribute parse error. Name: "%s", Value: "%s", Expected: %s, Got: %s`,63 `Attribute parse error. Name: "%s", Value: "%s", Expected: %s, Got: "%s"`, 48 64 testCase.AttrName, 49 65 testCase.AttrValue, 50 66 testCase.ExpectedOutput, 51 67 res, 68 ) 69 } 70 } 71 } 72 73 func TestURLProxifier(t *testing.T) { 74 u, _ := url.Parse("http://127.0.0.1/") 75 rc := &RequestConfig{BaseURL: u} 76 for _, testCase := range urlTestData { 77 newUrl, err := rc.ProxifyURI(testCase.Input) 78 if err != nil { 79 t.Errorf("Failed to parse URL: %s", testCase.Input) 80 } 81 if newUrl != testCase.ExpectedOutput { 82 t.Errorf( 83 `URL proxifier error. Expected: "%s", Got: "%s"`, 84 testCase.ExpectedOutput, 85 newUrl, 52 86 ) 53 87 }
Note:
See TracChangeset
for help on using the changeset viewer.