From 69c000388f2b0b24f56e1551609f19b31a1037ad Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 15 Jun 2015 21:45:23 -0400 Subject: view: json: Gracefully handle license lists and bogus licenses. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix-web/view/json.scm (license->json): Add 'match' form to handle bogus licenses. Co-Authored-By: Ludovic Courtès --- guix/web/view/json.scm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'guix/web/view') diff --git a/guix/web/view/json.scm b/guix/web/view/json.scm index 4fe45a2..e3f8bc1 100644 --- a/guix/web/view/json.scm +++ b/guix/web/view/json.scm @@ -32,10 +32,17 @@ generations-json)) (define (license->json license) - (json - (object - ("name" ,(license-name license)) - ("uri" ,(license-uri license))))) + (match license + ((? license? license) + (json + (object + ("name" ,(license-name license)) + ("uri" ,(license-uri license))))) + (_ ; a dubious license that we'd rather handle gracefully + (json + (object + ("name" ,(object->string license)) + ("uri" "http://www.gnu.org")))))) (define* (package->json package #:optional serialize-inputs?) (define (serialize-license package) -- cgit v1.2.3