Commit bdf85426 authored by Vladimir Sedach's avatar Vladimir Sedach

Removed uri-encode? and uri-decode? variables

parent 83948c3d
2019-08-16 Vladimir Sedach <vas@oneofus.la>
* Removed uri-encode? and uri-decode? variables.
uri-encode? and uri-decode? applied to the whole template,
which is too coarse-grained to be useful.
* Removed enable-uri-template-syntax function.
There was no correspond "disable" function, and using
......
......@@ -57,14 +57,6 @@ read-uri-template (function)
A function suitable for inserting into the readtable so you can
read URI templates from your own dispatch character.
uri-decode? (special variable)
Controls whether URI decoding/unescaping is done on the templated
value when destructuring. True by default.
uri-encode? (special variable)
Controls whether URI encoding/escaping is done on the templated value.
True by default.
uri-template (symbol)
The car of the list that the URI template reader produces. A
function or macro.
......
......@@ -20,17 +20,12 @@
(in-package #:uri-template2)
(defvar uri-decode? t
"Controls whether URI decoding/unescaping is done on the templated value when destructuring.
True by default.")
(defmacro weak-register-groups-bind (vars regex str &body body)
`(destructuring-bind (&optional ,@vars)
(coerce (nth-value 1 (scan-to-strings ,regex ,str)) 'list)
(declare (ignorable ,@vars))
,(when uri-decode?
`(setf ,@(loop for var in vars append
`(,var (when ,var (percent-encoding:decode ,var))))))
(setf ,@(loop for var in vars append
`(,var (when ,var (percent-encoding:decode ,var)))))
,@body))
(defmacro uri-template-bind ((template) uri &body body)
......
......@@ -23,16 +23,14 @@
(defpackage #:uri-template2
(:use #:cl #:cl-ppcre #:named-readtables)
(:export
;; common
;; readtable
#:uri-template
;; interpolation
#:read-uri-template
#:uri-encode?
;; destructuring
#:uri-template-bind
#:uri-decode?
;; RFC 2396 standard URI components
#:%uri-scheme
......
......@@ -20,10 +20,8 @@
(in-package #:uri-template2)
(parenscript:defpsmacro maybe-uri-encode (x)
(if uri-encode?
`(encode-u-r-i-component ,x)
x))
(parenscript:defpsmacro uri-encode (x)
`(encode-u-r-i-component ,x))
(parenscript:defpsmacro uri-template (&rest template-args)
`(+ ,@template-args))
......@@ -20,10 +20,6 @@
(in-package #:uri-template2)
(defvar uri-encode? t
"Controls whether URI encoding/escaping is done on the templated value.
True by default.")
(defun read-uri-template (stream &optional recursive-p)
"A function suitable for inserting into the readtable so you can
read URI templates from your own dispatch character."
......@@ -43,17 +39,15 @@ read URI templates from your own dispatch character."
'(#\Space #\Newline #\Tab #\)))
do (if (char= #\{ next-char)
(progn (collect-string)
(push `(maybe-uri-encode
(progn ,@(read-delimited-list #\} stream))
) template-accumulator))
(push `(uri-encode
(progn ,@(read-delimited-list #\} stream)))
template-accumulator))
(vector-push-extend next-char string-accumulator))
finally (unread-char next-char stream) (collect-string))
(reverse template-accumulator))))
(defmacro maybe-uri-encode (x)
(if uri-encode?
`(percent-encoding:encode (princ-to-string ,x))
x))
(defmacro uri-encode (x)
`(percent-encoding:encode (princ-to-string ,x)))
(defun uri-template (&rest template-args)
"The car of the list that the URI template reader produces. A
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment