Update validations for "url" and "uri" because of Go 1.6 changes

added checks for blank and fragment/suffix because of Go 1.6 change 617c93ce74 (diff-6c2d018290e298803c0c9419d8739885L195)
fix was to emulate browser and strip the '#' suffix prior to validation. see #237
pull/238/head
joeybloggs 9 years ago
parent 93bb347253
commit e7749ea250
  1. 4
      baked_in.go

@ -748,7 +748,7 @@ func IsURI(v *Validate, topStruct reflect.Value, currentStructOrField reflect.Va
s := field.String() s := field.String()
// checks needed as of Go 1.6 becuase of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195 // checks needed as of Go 1.6 because of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195
// emulate browser and strip the '#' suffix prior to validation. see issue-#237 // emulate browser and strip the '#' suffix prior to validation. see issue-#237
if i := strings.Index(s, "#"); i > -1 { if i := strings.Index(s, "#"); i > -1 {
s = s[:i] s = s[:i]
@ -777,7 +777,7 @@ func IsURL(v *Validate, topStruct reflect.Value, currentStructOrField reflect.Va
var i int var i int
s := field.String() s := field.String()
// checks needed as of Go 1.6 becuase of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195 // checks needed as of Go 1.6 because of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195
// emulate browser and strip the '#' suffix prior to validation. see issue-#237 // emulate browser and strip the '#' suffix prior to validation. see issue-#237
if i = strings.Index(s, "#"); i > -1 { if i = strings.Index(s, "#"); i > -1 {
s = s[:i] s = s[:i]

Loading…
Cancel
Save