diff --git a/.circleci/config.yml b/.circleci/config.yml
index 88d64aa..ade5000 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -30,19 +30,19 @@ defaults_gradle: &defaults_gradle
path: build/reports/
jobs:
- build_gradle_jdk17:
+ build_gradle_jdk18:
<<: *defaults
docker:
- - image: cimg/openjdk:17.0
+ - image: cimg/openjdk:18.0
<<: *defaults_gradle
- build_gradle_jdk8:
+ build_gradle_jdk11:
<<: *defaults
docker:
- - image: cimg/openjdk:8.0
+ - image: cimg/openjdk:11.0
<<: *defaults_gradle
@@ -50,5 +50,5 @@ workflows:
version: 2
gradle:
jobs:
- - build_gradle_jdk8
- - build_gradle_jdk17
+ - build_gradle_jdk11
+ - build_gradle_jdk18
diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 4a473de..a0b7843 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
- java-version: [ 1.8, 11, 17 ]
+ java-version: [ 11, 18 ]
steps:
- uses: actions/checkout@v2
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..b1077fb
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 51e4cd8..95b6160 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 797acea..0000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/README.md b/README.md
index 3727d81..767f37f 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-[](http://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/isgd-shorten/releases/latest) [](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten)
+[](https://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/isgd-shorten/releases/latest) [](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten)
-[](https://snyk.io/test/github/ethauvin/isgd-shorten?targetFile=pom.xml) [](https://sonarcloud.io/dashboard?id=ethauvin_isgd-shorten) [](https://github.com/ethauvin/isgd-shorten/actions/workflows/gradle.yml) [](https://circleci.com/gh/ethauvin/isgd-shorten/tree/master)
+[](https://sonarcloud.io/dashboard?id=ethauvin_isgd-shorten) [](https://github.com/ethauvin/isgd-shorten/actions/workflows/gradle.yml) [](https://circleci.com/gh/ethauvin/isgd-shorten/tree/master)
# [is.gd](https://is.gd/developers.php) Shortener for Kotlin/Java/Android
@@ -44,7 +44,7 @@ Isgd.shorten(url = url, shorturl="foobar", callback = "test", logstats = true, f
```
returns:
-```json
+```js
test({ "shorturl": "https://is.gd/foobar" });
```
### Gradle
@@ -52,11 +52,15 @@ test({ "shorturl": "https://is.gd/foobar" });
To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/isgd-shorten/blob/master/examples/build.gradle.kts) file:
```gradle
+repositories {
+ mavenCentral()
+}
+
dependencies {
implementation("net.thauvin.erik:isgd-shorten:0.9.2")
}
```
-Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/artifact/net.thauvin.erik/isgd-shorten/0.9.2/jar).
+Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten).
### Errors
@@ -64,7 +68,7 @@ An `IsgdException` is thrown when an API error occurs. The error message (text,
```kotlin
try {
- Isgd.shorten("http://is.gd/Pt2sET") // already shorten
+ Isgd.shorten("https://is.gd/Pt2sET") // already shorten
} catch (e: IsgdException)
println("Status Code: ${e.statusCode}")
println("${e.message})
diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml
index 7d98402..a9514a0 100644
--- a/bitbucket-pipelines.yml
+++ b/bitbucket-pipelines.yml
@@ -1,4 +1,4 @@
-image: openjdk:8
+image: maven:3-openjdk-18
pipelines:
default:
diff --git a/build.gradle.kts b/build.gradle.kts
index 0eed035..29c3280 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -3,18 +3,18 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
- id("com.github.ben-manes.versions") version "0.40.0"
- id("io.gitlab.arturbosch.detekt") version "1.19.0"
+ id("com.github.ben-manes.versions") version "0.42.0"
+ id("io.gitlab.arturbosch.detekt") version "1.21.0"
id("java")
id("java-library")
id("maven-publish")
id("net.thauvin.erik.gradle.semver") version "1.0.4"
- id("org.jetbrains.dokka") version "1.6.10"
- id("org.jetbrains.kotlinx.kover") version "0.4.4"
- id("org.sonarqube") version "3.3"
+ id("org.jetbrains.dokka") version "1.7.10"
+ id("org.jetbrains.kotlinx.kover") version "0.6.0"
+ id("org.sonarqube") version "3.4.0.2513"
id("signing")
- kotlin("jvm") version "1.6.10"
- kotlin("kapt") version "1.6.10"
+ kotlin("jvm") version "1.7.20"
+ kotlin("kapt") version "1.7.20"
}
group = "net.thauvin.erik"
@@ -56,7 +56,7 @@ sonarqube {
property("sonar.organization", "ethauvin-github")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.sourceEncoding", "UTF-8")
- property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/report.xml")
+ property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/xml/report.xml")
}
}
@@ -120,7 +120,7 @@ tasks {
register("deploy") {
description = "Copies all needed files to the $deployDir directory."
group = PublishingPlugin.PUBLISH_TASK_GROUP
- dependsOn(build, jar)
+ dependsOn(clean, wrapper, build, jar)
outputs.dir(deployDir)
inputs.files(copyToDeploy)
mustRunAfter(clean)
diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts
index 89cc257..2af7a7d 100644
--- a/examples/build.gradle.kts
+++ b/examples/build.gradle.kts
@@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("application")
- id("com.github.ben-manes.versions") version "0.40.0"
- kotlin("jvm") version "1.6.10"
+ id("com.github.ben-manes.versions") version "0.42.0"
+ kotlin("jvm") version "1.7.20"
}
// ./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
diff --git a/examples/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties
index 2e6e589..ae04661 100644
--- a/examples/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 2e6e589..ae04661 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/pom.xml b/pom.xml
index 88347c0..24cf88e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,7 +40,7 @@
org.jetbrains.kotlin
kotlin-bom
- 1.5.31
+ 1.7.20
pom
import
@@ -50,7 +50,7 @@
org.jetbrains.kotlin
kotlin-stdlib-jdk8
- 1.5.31
+ 1.7.20
compile
diff --git a/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt b/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt
index 161b259..676f6f2 100644
--- a/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt
+++ b/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt
@@ -45,7 +45,7 @@ enum class Format(val type: String) {
}
fun String.encode(): String {
- return URLEncoder.encode(this, StandardCharsets.UTF_8.name())
+ return URLEncoder.encode(this, StandardCharsets.UTF_8).replace("+", "%20").replace("*", "%2A").replace("%7E", "~")
}
/**
@@ -56,8 +56,8 @@ class Isgd private constructor() {
private fun callApi(url: String): String {
val connection = URL(url).openConnection() as HttpURLConnection
connection.setRequestProperty(
- "User-Agent",
- "Mozilla/5.0 (Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0"
+ "User-Agent",
+ "Mozilla/5.0 (Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
)
if (connection.responseCode in 200..399) {
return connection.inputStream.bufferedReader().readText()
@@ -77,10 +77,10 @@ class Isgd private constructor() {
@JvmOverloads
@Throws(IsgdException::class)
fun lookup(
- shorturl: String,
- callback: String = "",
- format: Format = Format.SIMPLE,
- isVgd: Boolean = false
+ shorturl: String,
+ callback: String = "",
+ format: Format = Format.SIMPLE,
+ isVgd: Boolean = false
): String {
if (shorturl.isEmpty()) {
throw IllegalArgumentException("Please specify a valid short URL to lookup.")
@@ -104,12 +104,12 @@ class Isgd private constructor() {
@JvmOverloads
@Throws(IsgdException::class)
fun shorten(
- url: String,
- shorturl: String = "",
- callback: String = "",
- logstats: Boolean = false,
- format: Format = Format.SIMPLE,
- isVgd: Boolean = false
+ url: String,
+ shorturl: String = "",
+ callback: String = "",
+ logstats: Boolean = false,
+ format: Format = Format.SIMPLE,
+ isVgd: Boolean = false
): String {
if (url.isEmpty()) {
throw IllegalArgumentException("Please enter a valid URL to shorten.")
diff --git a/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt b/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
index c746e2c..1ffd292 100644
--- a/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
@@ -53,8 +53,8 @@ class IsgdTest {
try {
Isgd.shorten(shortUrl)
} catch (e: IsgdException) {
- assertTrue(e.statusCode == 400, "status code == 400")
- assertTrue(e.message!!.startsWith("Error: "), "error message")
+ assertTrue(e.statusCode == 400, "status code != 400")
+ assertTrue(e.message!!.startsWith("Error: "), "error message is invalid")
}
}