Skip to content

Commit

Permalink
Rename util to path, and move all path funcs there
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuswilms committed Mar 30, 2018
1 parent ef9cf7c commit 51c3185
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 0 additions & 26 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -401,28 +400,3 @@ func lookupNodeURL(url string) string {
"",
)
}

// Finds an order number embedded into given path/URL segment and
// returns it. If none is found, returns 0.
func orderNumber(segment string) uint64 {
s := NodePathTitleRegexp.FindStringSubmatch(segment)

if len(s) > 2 {
parsed, _ := strconv.ParseUint(s[0], 10, 64)
return parsed
}
return 0
}

// Removes order numbers from path/URL segment, if present.
func removeOrderNumber(segment string) string {
s := NodePathTitleRegexp.FindStringSubmatch(segment)

if len(s) == 0 {
return segment
}
if len(s) > 2 {
return s[2]
}
return s[1]
}
26 changes: 26 additions & 0 deletions util.go → path.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"log"
"path/filepath"
"regexp"
"strconv"
"strings"
)

Expand Down Expand Up @@ -83,3 +84,28 @@ func anyPathSegmentMatches(path string, r *regexp.Regexp) bool {
}
return false
}

// Finds an order number embedded into given path segment and
// returns it. If none is found, returns 0.
func orderNumber(segment string) uint64 {
s := NodePathTitleRegexp.FindStringSubmatch(segment)

if len(s) > 2 {
parsed, _ := strconv.ParseUint(s[0], 10, 64)
return parsed
}
return 0
}

// Removes order numbers from path segment, if present.
func removeOrderNumber(segment string) string {
s := NodePathTitleRegexp.FindStringSubmatch(segment)

if len(s) == 0 {
return segment
}
if len(s) > 2 {
return s[2]
}
return s[1]
}

0 comments on commit 51c3185

Please sign in to comment.