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