Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(834)

Side by Side Diff: src/pkg/net/url/url.go

Issue 11698045: code review 11698045: net/url: prepend slash to path in String() (Closed)
Patch Set: diff -r 86a2e482982f https://code.google.com/p/go Created 10 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/net/url/url_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package url parses URLs and implements query escaping. 5 // Package url parses URLs and implements query escaping.
6 // See RFC 3986. 6 // See RFC 3986.
7 package url 7 package url
8 8
9 import ( 9 import (
10 "bytes" 10 "bytes"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 if u.Scheme != "" || u.Host != "" || u.User != nil { 452 if u.Scheme != "" || u.Host != "" || u.User != nil {
453 buf.WriteString("//") 453 buf.WriteString("//")
454 if u := u.User; u != nil { 454 if u := u.User; u != nil {
455 buf.WriteString(u.String()) 455 buf.WriteString(u.String())
456 buf.WriteByte('@') 456 buf.WriteByte('@')
457 } 457 }
458 if h := u.Host; h != "" { 458 if h := u.Host; h != "" {
459 buf.WriteString(h) 459 buf.WriteString(h)
460 } 460 }
461 } 461 }
462 if u.Path != "" {
463 if u.Path[0] != '/' {
0xjnml 2013/07/24 07:49:04 You can save two lines by: if u.Path != "" && u.P
464 buf.WriteByte('/')
465 }
466 }
462 buf.WriteString(escape(u.Path, encodePath)) 467 buf.WriteString(escape(u.Path, encodePath))
463 } 468 }
464 if u.RawQuery != "" { 469 if u.RawQuery != "" {
465 buf.WriteByte('?') 470 buf.WriteByte('?')
466 buf.WriteString(u.RawQuery) 471 buf.WriteString(u.RawQuery)
467 } 472 }
468 if u.Fragment != "" { 473 if u.Fragment != "" {
469 buf.WriteByte('#') 474 buf.WriteByte('#')
470 buf.WriteString(escape(u.Fragment, encodeFragment)) 475 buf.WriteString(escape(u.Fragment, encodeFragment))
471 } 476 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 } else { 693 } else {
689 if strings.HasPrefix(result, "//") { 694 if strings.HasPrefix(result, "//") {
690 result = u.Scheme + ":" + result 695 result = u.Scheme + ":" + result
691 } 696 }
692 } 697 }
693 if u.RawQuery != "" { 698 if u.RawQuery != "" {
694 result += "?" + u.RawQuery 699 result += "?" + u.RawQuery
695 } 700 }
696 return result 701 return result
697 } 702 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/net/url/url_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b