Skip to content

Commit

Permalink
Remote unused unquoteSassString function
Browse files Browse the repository at this point in the history
  • Loading branch information
achew22 committed Feb 24, 2019
1 parent cffc2c2 commit 02df7bb
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions gazelle/fileinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ limitations under the License.
package gazelle

import (
"bytes"
"fmt"
"log"
"os"
"path/filepath"
"sort"
"strconv"

"github.com/bazelbuild/rules_sass/gazelle/parser"
)
Expand Down Expand Up @@ -121,30 +119,3 @@ func sassFileInfo(dir, name string) FileInfo {

return info
}

// unquoteSassString takes a string that has a complex quoting around it
// and returns a string without the complex quoting.
func unquoteSassString(q []byte) string {
// Adjust quotes so that Unquote is happy. We need a double quoted string
// without unescaped double quote characters inside.
noQuotes := bytes.Split(q[1:len(q)-1], []byte{'"'})
if len(noQuotes) != 1 {
for i := 0; i < len(noQuotes)-1; i++ {
if len(noQuotes[i]) == 0 || noQuotes[i][len(noQuotes[i])-1] != '\\' {
noQuotes[i] = append(noQuotes[i], '\\')
}
}
q = append([]byte{'"'}, bytes.Join(noQuotes, []byte{'"'})...)
q = append(q, '"')
}
if q[0] == '\'' {
q[0] = '"'
q[len(q)-1] = '"'
}

s, err := strconv.Unquote(string(q))
if err != nil {
log.Panicf("unquoting string literal %s from sass: %v", q, err)
}
return s
}

0 comments on commit 02df7bb

Please sign in to comment.