swarm/api: use path.Ext instead strings.LastIndex in MultiResolver.Resolve

This commit is contained in:
Janos Guljas 2017-12-04 22:56:52 +01:00
parent e451b65fae
commit 1dc19de5da
1 changed files with 3 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"path"
"regexp" "regexp"
"strings" "strings"
"sync" "sync"
@ -83,8 +84,8 @@ func NewMultiResolver(opts ...MultiResolverOption) (m *MultiResolver) {
// will be returned. // will be returned.
func (m MultiResolver) Resolve(addr string) (h common.Hash, err error) { func (m MultiResolver) Resolve(addr string) (h common.Hash, err error) {
rs := m.resolvers[""] rs := m.resolvers[""]
if i := strings.LastIndex(addr, "."); i >= 0 { if ext := path.Ext(addr); ext != "" {
rstld, ok := m.resolvers[addr[i+1:]] rstld, ok := m.resolvers[ext[1:]]
if ok { if ok {
rs = rstld rs = rstld
} }