Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nulls in link #29

Open
kkolyan opened this issue May 21, 2024 · 2 comments
Open

Nulls in link #29

kkolyan opened this issue May 21, 2024 · 2 comments

Comments

@kkolyan
Copy link

kkolyan commented May 21, 2024

In new IDEA version it generates URL with nulls instead of some critical URL parts:
https://nullnull/null/blob/147b777baa25147742e85e1b9242051efe354e9f/GlipBot.postman_collection.json#L3

IntelliJ IDEA 2024.1 (Ultimate Edition)
Build #IU-241.14494.240, built on March 28, 2024
Licensed to RingCentral, Inc. /  
Subscription is active until January 3, 2025.
Runtime version: 17.0.10+8-b1207.12 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.4.1
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 8
Metal Rendering is ON
Registry:
  analyze.exceptions.on.the.fly=true
  ide.experimental.ui=true
  terminal.new.ui=true
  scala.erase.compiler.process.jdk.once=false
  org.toml.json.schema=false
Non-Bundled Plugins:
  net.sjrx.intellij.plugins.systemdunitfiles (223.240127.136)
  me.mbolotov.json.schema.generator (1.1)
  com.jetbrains.rust (241.25989.180)
  com.vermouthx.idea (1.16.0)
  org.jetbrains.plugins.go-template (241.14494.150)
  com.khmelyuk.multirun (1.14.1)
  com.markskelton.one-dark-theme (5.10.0)
  name.kropp.intellij.makefile (241.14494.150)
  org.jetbrains.plugins.go (241.14494.240)
  org.jetbrains.plugins.ruby (241.14494.240)
  Pythonid (241.14494.314)
  com.intellij.nativeDebug (241.14494.234)
  com.intellij.mermaid (0.0.21+IJ.232)
  ru.artyushov (1.5.0)
  com.intellij.ml.llm (241.14494.320)
  ru.meanmail.plugin.requirements (2022.4.1)
  com.intellij.bigdatatools.core (241.14494.240)
  com.github.kawamataryo.copygithublink (0.5.3)
  com.google.gct.core (24.4.3-api-version-223)
  com.intellij.bigdatatools.kafka (241.14494.158)
  com.jetbrains.php (241.14494.240)
  org.intellij.scala (2024.1.20)
Kotlin: 241.14494.240-IJ
@kkolyan kkolyan changed the title Nulls in link (https://nullnull/null/blob/147b777baa25147742e85e1b9242051efe354e9f/myfile.json#L3) Nulls in link May 21, 2024
@yusefnapora
Copy link

I'm also getting nulls in the URL, which in my case I think is related to having . characters in the path before the .git extension, as in this comment.

I looked a bit at the regex in https://github.com/kawamataryo/copy-git-link/blob/main/src/main/kotlin/com/github/kawamataryo/copygitlink/utils/utils.kt#L41 and it seems like you could simplify things by just grabbing everything after the host & port and then removing any .git suffix from the path afterwards. So something like:

fun getRepositoryPathFromRemoteUrl(
    remoteUrl: String,
): String {
    val result =
        Regex(".*(?:@|//)(.[^:/]*)(:?:[0-9]{1,4})?(.*)\$").matchEntire(
            remoteUrl
        )
    val path = result?.groupValues?.get(3)?.removeSuffix(".git") ?: ""
    return result?.groupValues?.get(1) + result?.groupValues?.get(2) + "/" + path
}

I don't have a kotlin environment set up on this machine, but if you like I could make a little PR to that effect this weekend.

@dustinblue
Copy link

Been having this null issue then realized there is built in support for this, at least PHPStorm. Highlight a line right-click, open in Github

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants