From 27832f1a0081ef423342a3162ce8ed5f0be66d82 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 26 Oct 2017 11:54:56 -0400 Subject: Fix/url parsing (#448) * Fix url formatting * Optimize imports --- .../pitchedapps/frost/facebook/FbUrlFormatter.kt | 1 + .../com/pitchedapps/frost/facebook/FbUrlTest.kt | 13 +- projectFilesBackup/.idea/workspace.xml | 4987 ++++++++++++++++++++ 3 files changed, 4998 insertions(+), 3 deletions(-) create mode 100644 projectFilesBackup/.idea/workspace.xml 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 4db75fff..22fc275f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt @@ -31,6 +31,7 @@ class FbUrlFormatter(url: String) { var cleanedUrl = url discardable.forEach { cleanedUrl = cleanedUrl.replace(it, "", true) } converter.forEach { (k, v) -> cleanedUrl = cleanedUrl.replace(k, v, true) } + if (cleanedUrl != url) cleanedUrl = cleanedUrl.replaceFirst("&", "?") cleanedUrl = URLDecoder.decode(cleanedUrl, StandardCharsets.UTF_8.name()) val qm = cleanedUrl.indexOf("?") if (qm > -1) { diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt index 57589b5e..5ac484b5 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt @@ -1,9 +1,6 @@ package com.pitchedapps.frost.facebook -import okhttp3.HttpUrl -import okio.Utf8 import org.junit.Test -import java.net.URLDecoder import kotlin.test.assertEquals @@ -36,6 +33,16 @@ class FbUrlTest { assertFbFormat("$prefix$suffix", "$prefix&ref=hello$suffix") } + /** + * Unnecessary wraps should be removed & the query items should be bound properly (first & to ?) + */ + @Test + fun queryConversion() { + val url = "https://m.facebook.com/l.php?u=https%3A%2F%2Fgoogle.ca&h=hi" + val expected = "https://google.ca?h=hi" + assertFbFormat(expected, url) + } + @Test fun doubleDash() { assertFbFormat("${FB_URL_BASE}relative", "$FB_URL_BASE/relative") diff --git a/projectFilesBackup/.idea/workspace.xml b/projectFilesBackup/.idea/workspace.xml new file mode 100644 index 00000000..d1ab613b --- /dev/null +++ b/projectFilesBackup/.idea/workspace.xml @@ -0,0 +1,4987 @@ + + + + + + + + + + + + + + + com.mikepenz + community-material-typeface + 1.5.54.2 + JCenter + + + com.davemorrissey.labs + subsampling-scale-image-view + 3.6.0 + JCenter + + + com.github.pwittchen + reactivenetwork-rx2 + 0.11.0 + JCenter + + + junit + junit + 4.12 + JCenter + + + com.mikepenz + material-design-iconic-typeface + 2.2.0.2 + JCenter + + + com.anjlab.android.iab.v3 + library + 1.0.44 + JCenter + + + com.squareup.okhttp3 + okhttp + 3.8.1 + JCenter + + + org.apache.commons + commons-text + 1.1 + JCenter + + + org.jsoup + jsoup + 1.10.3 + JCenter + + + com.android.support.test + runner + 0.6-alpha + Android Repository + + + org.jetbrains.kotlin + kotlin-test-junit + 1.1.4-2 + JCenter + + + com.sothree.slidinguppanel + library + 3.3.1 + JCenter + + + org.jetbrains.kotlin + kotlin-stdlib + 1.1.4-2 + JCenter + + + com.android.support.test + rules + 0.6-alpha + Android Repository + + + 1503250555256 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + contentDisposition + restarter + onsing + r.layout + loading + seekto + setico + parent + videoViewImpl + s + searchview + browser + setc + onba + show + onfinishli + ?. + upperMinimizedY + lowerVideoPadding + onFade + setontou + videoDimensions + setont + shouldpa + c + control + setcontrol + pause + logPurchase + video. + + + implementation + api + &apos; + frost_name + String + L.d + c + Implementation + FACEBOOK_BLUE + + finish + context + "\\\\$1 " to "%$1" + "\\\\$1 " to "%$1", + % + "\\$1 " $2, + "\\\\$1 " $2, + Night }, + Night: Int by + ColorNight + _night", + ThemePrefs + u003C + Triple<List<FrostThread>, FrostLink?, List<FrostLink>> + event.rawX + event.rawY + ValueCallback<Array<Uri>?> + + + C:\Users\User7681\.gradle\caches\transforms-1\files-1.1\core-c2dd5d6.aar\4503508a24ede5e6e4c95d7a75c442e7\jars\classes.jar!\ca\allanwang\kau\utils + C:\Users\User7681\PA\Frost-for-Facebook\app\src\main\kotlin\com\pitchedapps\frost\services + C:\Users\User7681\PA\Frost-for-Facebook\app\src\main\kotlin\com\pitchedapps\frost\settings + C:\Users\User7681\PA\Frost-for-Facebook + C:\Users\User7681\PA\Frost-for-Facebook\app\src\main\res\values-de + C:\Users\User7681\PA\Frost-for-Facebook\app\src\main\res\values + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1497996592535 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/ca.allanwang.kau/core/e803969433/ed1651c9d290aa246e52b6733264cfba1b67b2b3/core-e803969433-sources.jar!/ca/allanwang/kau/swipe/SwipeBackPage.kt + 55 + + + + jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.8.1/fc70ffa234e7e77741867d38b341d162ec1ec01e/okhttp-3.8.1-sources.jar!/okhttp3/Request.java + 141 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3