Skip to content

Instantly share code, notes, and snippets.

@apropos-cast
Created February 6, 2020 19:01
Show Gist options
  • Save apropos-cast/3cb0fbd934826cc0b97b9204cd57fb43 to your computer and use it in GitHub Desktop.
Save apropos-cast/3cb0fbd934826cc0b97b9204cd57fb43 to your computer and use it in GitHub Desktop.
February 6, 2020 - Apropos

Show date: February 6, 2020

Topics

Multi-stage builds in Docker

Markdown Editor Single Page Application

50% off during launch: https://purelyfunctional.tv/courses/markdown-editor/

REPL Exercise

Parse query parameters

URLs can have optional query parameters. They are the key-value pairs that follow the path.

Write a function that takes a URL (represented as a string) and parses out the query parameters into a hashmap.

Notes:

  • The query string is the string containing the query parameters. It appears after the ? and before a #. Ex: https://lispcast.com/search?q=clojure#page2
  • The keys and values are URL Encoded. You can use java.net.URLDecoder/decode to decode them.
  • The key-value pairs are separated by &. Ex: a=1&b=2
  • Each key-value pair contains the key, followed by =, followed by the value. Ex: a=1

Bonus:

Query parameters can contain duplicate keys. Handle them gracefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment