Skip to content

Commit

Permalink
Support %S as an equivalent to %s
Browse files Browse the repository at this point in the history
  • Loading branch information
juliandescottes committed Aug 20, 2016
1 parent 8b14ae2 commit a60ea5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The placeholders in the format string are marked by `%` and are followed by one
* `f` — yields a float as is; see notes on precision above
* `g` — yields a float as is; see notes on precision above
* `o` — yields an integer as an octal number
* `s` — yields a string as is
* `s` or `S` — yields a string as is
* `t` — yields `true` or `false`
* `T` — yields the type of the argument<sup><a href="#fn-1" name="fn-ref-1">1</a></sup>
* `v` — yields the primitive value of the specified argument
Expand Down
3 changes: 2 additions & 1 deletion src/sprintf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
not_json: /[^j]/,
text: /^[^\x25]+/,
modulo: /^\x25{2}/,
placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosStTuvxX])/,
key: /^([a-z_][a-z_\d]*)/i,
key_access: /^\.([a-z_][a-z_\d]*)/i,
index_access: /^\[(\d+)\]/,
Expand Down Expand Up @@ -93,6 +93,7 @@
arg = arg.toString(8)
break
case 's':
case 'S':
arg = String(arg)
arg = (match[7] ? arg.substring(0, match[7]) : arg)
break
Expand Down

0 comments on commit a60ea5d

Please sign in to comment.