diff options
author | Allan Wang <me@allanwang.ca> | 2017-08-03 22:21:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-03 22:21:51 -0700 |
commit | 7746e63373c905faa6d7e45e45fffc48d3ffff85 (patch) | |
tree | 5d1bd4338a722619bb892abb308b369abc61f396 /app/src/main/kotlin/com/pitchedapps/frost/facebook | |
parent | 5583f519dd7c4843f045029b0e48fd882dd79c71 (diff) | |
download | frost-7746e63373c905faa6d7e45e45fffc48d3ffff85.tar.gz frost-7746e63373c905faa6d7e45e45fffc48d3ffff85.tar.bz2 frost-7746e63373c905faa6d7e45e45fffc48d3ffff85.zip |
Add IM notifications, FAQ, video uploading, and geolocations (#107)
* Test canary
* Update activities to use kau base
* Update dependencies
* Cherry pick faq
* Update kau and add faq
* Add readme badges
* Add im notifications and video uploading
* Update theme
* Update and fix unit tests
* Add geolocation
* Prepare alpha test
* Remove explicit nonnull request
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt index 622be067..7cd93d14 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt @@ -1,5 +1,7 @@ package com.pitchedapps.frost.facebook +import com.pitchedapps.frost.utils.L + /** * Created by Allan Wang on 2017-07-07. * @@ -13,22 +15,27 @@ class FbUrlFormatter(url: String) { val cleaned: String init { - var cleanedUrl = url - discardable.forEach { cleanedUrl = cleanedUrl.replace(it, "", true) } - val changed = cleanedUrl != url //note that discardables strip away the first ? - decoder.forEach { (k, v) -> cleanedUrl = cleanedUrl.replace(k, v, true) } - val qm = cleanedUrl.indexOf(if (changed) "&" else "?") - if (qm > -1) { - cleanedUrl.substring(qm + 1).split("&").forEach { - val p = it.split("=") - queries.put(p[0], p.elementAtOrNull(1) ?: "") + if (url.isNullOrBlank()) cleaned = "" + else { + var cleanedUrl = url + discardable.forEach { cleanedUrl = cleanedUrl.replace(it, "", true) } + val changed = cleanedUrl != url //note that discardables strip away the first ? + decoder.forEach { (k, v) -> cleanedUrl = cleanedUrl.replace(k, v, true) } + val qm = cleanedUrl.indexOf(if (changed) "&" else "?") + if (qm > -1) { + cleanedUrl.substring(qm + 1).split("&").forEach { + val p = it.split("=") + queries.put(p[0], p.elementAtOrNull(1) ?: "") + } + cleanedUrl = cleanedUrl.substring(0, qm) } - cleanedUrl = cleanedUrl.substring(0, qm) + discardableQueries.forEach { queries.remove(it) } + if (cleanedUrl.startsWith("#!/")) cleanedUrl = cleanedUrl.substring(2) + if (cleanedUrl.startsWith("/")) cleanedUrl = FB_URL_BASE + cleanedUrl.substring(1) + cleanedUrl = cleanedUrl.replaceFirst(".facebook.com//", ".facebook.com/") //sometimes we are given a bad url + L.v("Formatted url from $url to $cleanedUrl") + cleaned = cleanedUrl } - discardableQueries.forEach { queries.remove(it) } - if (cleanedUrl.startsWith("#!/")) cleanedUrl = cleanedUrl.substring(2) - if (cleanedUrl.startsWith("/")) cleanedUrl = FB_URL_BASE + cleanedUrl.substring(1) - cleaned = cleanedUrl } override fun toString(): String { |