From 94f74001697394654bd51e6d2aeca4a762909fcb Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Wed, 16 Nov 2022 13:05:09 +0100 Subject: [PATCH] Added a readme --- .gitignore | 1 + README.md | 22 ++++++++++++++++++++++ landerctl | 3 +++ 3 files changed, 26 insertions(+) create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 6654b8d..daffc58 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build/ compile_commands.json +lander.data diff --git a/README.md b/README.md new file mode 100644 index 0000000..9f712ca --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Lander + +## The idea + +A URL shortener has always been on my list of things I'd like to write myself. +It's simple, yet useful. + +for our Algorithms & Datastructures 3 class, we had to implement three +different tries (Patricia trie, ternary trie, and a custom one). Considering +these are efficient string-based search trees, this gave me the idea to use it +as the backend for a URL shortener! + +This implementation currently uses a ternary trie as its search tree. The +persistence model is very simple; I simply append a line to a text file every +time a URL is added, and add the lines of this file to the trie on startup. The +trie is stored completely im memory, and no I/O operations are required when +requesting a redirect. This makes the server very fast. + +## The name + +I gave up giving my projects original names a long time ago, so now I just use +the names of my friends ;p diff --git a/landerctl b/landerctl index 518b019..a2e94cc 100755 --- a/landerctl +++ b/landerctl @@ -10,4 +10,7 @@ if [ "$1" = add ]; then -H "X-Api-Key: $API_KEY" \ "$URL/$2" echo "$URL/$2" + +elif [ "$1" = get ]; then + curl -is "$URL/$2" | grep -Po '(?<=location: ).*' fi