Skip to content

Commit

Permalink
unit test refs #29
Browse files Browse the repository at this point in the history
  • Loading branch information
drieks committed Mar 19, 2021
1 parent 5a03ad3 commit a96e681
Show file tree
Hide file tree
Showing 5 changed files with 2,927 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.kickstarter.libs.utils

import android.content.Context
import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.content.ContextCompat
import com.kickstarter.R

object UrlUtils {

private const val KEY_REF = "ref"

fun appendPath(baseUrl: String, path: String): String {
val uriBuilder = Uri.parse(baseUrl).buildUpon()
uriBuilder.appendEncodedPath(path)

return uriBuilder.build().toString()
}

fun appendQueryParameter(baseUrl: String, key: String, value: String): String {
val uriBuilder = Uri.parse(baseUrl).buildUpon()
uriBuilder.appendQueryParameter(key, value)

return uriBuilder.build().toString()
}

fun appendRefTag(baseUrl: String, tag: String): String {
return appendQueryParameter(baseUrl, KEY_REF, tag)
}

fun baseCustomTabsIntent(context: Context): CustomTabsIntent {
val builder = CustomTabsIntent.Builder()

builder.setShowTitle(true)
builder.setToolbarColor(ContextCompat.getColor(context, R.color.primary))

return builder.build()
}

fun refTag(url: String): String? {
return Uri.parse(url).getQueryParameter(KEY_REF)
}
}
Loading

0 comments on commit a96e681

Please sign in to comment.