# Linking to Custom Scheme

**URL:** https://meta.discourse.org/t/linking-to-custom-scheme/254729
**Category:** Development
**Created:** [February 10, 2023, 3:39am UTC](https://meta.discourse.org/t/linking-to-custom-scheme/254729 "2023-02-10T03:39:03Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jays10](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@jays10](https://meta.discourse.org/u/jays10)
#### Post date: [February 10, 2023, 3:39am UTC](https://meta.discourse.org/t/linking-to-custom-scheme/254729/1 "2023-02-10T03:39:03Z")

</div>

Hello All,

We are setting up our new discourse internal environment and I was able to setup a custom URL scheme to link to an internal resource on the network, I wanted to add an easy button when making a new post which I was able to do but I want to be able to use the highlighted text for the link title as well as for the actual link itself. Right now I am just using an apply surround to insert what we need into a link but we have to manually change the link title, see the code below.

```plaintext
<script type="text/discourse-plugin" version="1.0">
api.onToolbarCreate(toolbar => {
    toolbar.addButton({
        id: "dms_button",
        group: "fontStyles",
        icon: "fab-wikipedia-w",
        perform: e => e.applySurround("[id_here](INET://", ')')
    });
});
</script>

```

user enters 123456 \> that applies this around the highlighted text `[id_here](INET://123456)`

I did look through the code but I could not find anything that would help me accomplish what we are looking to do. Is there anyway to use the highlighted text in the link title as well?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [February 11, 2023, 11:05am UTC](https://meta.discourse.org/t/linking-to-custom-scheme/254729/2 "2023-02-11T11:05:24Z")

</div>

So you want the text you select to appear twice?

I don’t think that function will allow you to do that?

Have you thought about overriding the onebox logic to work with your protocol?

---

<div class="post-metadata">

### Author: ![jays10](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@jays10](https://meta.discourse.org/u/jays10)
#### Post date: [February 14, 2023, 6:18pm UTC](https://meta.discourse.org/t/linking-to-custom-scheme/254729/3 "2023-02-14T18:18:15Z")

</div>

The protocol works fine, I can use inet:// as needed but I was just looking for an easy way for user to insert the custom URL into a post. In the previous form (phpbb) we made a custom bbcode for the link that worked however I was looking for an easier solution with discourse.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [February 14, 2023, 6:33pm UTC](https://meta.discourse.org/t/linking-to-custom-scheme/254729/4 "2023-02-14T18:33:38Z")

</div>

so Discourse already supports oneboxing of `inet://` links?

---

<div class="post-metadata">

### Author: ![jays10](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@jays10](https://meta.discourse.org/u/jays10)
#### Post date: [February 14, 2023, 6:40pm UTC](https://meta.discourse.org/t/linking-to-custom-scheme/254729/5 "2023-02-14T18:40:20Z")

</div>

It does not out of the box. So what you’re referring to is to create a onebox plugin for inet:// which will format the link the way I need?

So when user enter inet://12345  
onebox preview will actually contain the proper formatted link?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [February 14, 2023, 6:41pm UTC](https://meta.discourse.org/t/linking-to-custom-scheme/254729/6 "2023-02-14T18:41:44Z")

</div>

My suggestion was that rather than doing something so low level in the composer, “simply” modify the oneboxing subsystem so it formats `inet://` links just like `https://` links.

Specifically I’m referring to the way it formats inline like so: [Dark/Light Mode Toggle - #20 by jordan.vidrine](https://meta.discourse.org/t/dark-light-mode-toggle/215585/20)

All I had to do was paste the link, Discourse looked at the target and created a nice linked title for me from the og tags.

This of course assumes your organisation has control over the og tags on the target linked pages.
