Skip to content

Conversation

@silverwind
Copy link
Member

@silverwind silverwind commented Dec 23, 2025

Given the following markdown:

http://localhost:3500/silverwind/symlink-test/commit/a832c723cd116df44cce6271c4a89afa4d8ec670
http://localhost:3500/silverwind/remap-css/commit/19fe6cdf81f7ec50b8cac2d6c28fe7c42c1ffe14
http://github.com/silverwind/symlink-test/commit/a832c723cd116df44cce6271c4a89afa4d8ec670

Previously, all links would turn into hash link, even ones to external sites:

Screenshot 2025-12-23 at 19 19 13

After this change, only links to the current instance, as identified by setting.AppURL are turned into hash links:

Screenshot 2025-12-23 at 19 18 56

There is still one notable difference with GitHub where the second link should render like user/repo@<hash>, not <hash> as currently, I would like to fix that here as well.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 23, 2025
@silverwind silverwind marked this pull request as draft December 23, 2025 18:24
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Dec 23, 2025
Comment on lines +106 to +107
// only turn commit links to the current instance into hash link
if !strings.HasPrefix(strings.ToLower(ret.FullURL), strings.ToLower(setting.AppURL)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multidomain support #8697

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what do we check instead of setting.AppURL? Is there a slice of "current app urls" somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no "current app urls" at the moment.

Copy link
Member Author

@silverwind silverwind Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make server.ROOT_URL accept multiple URLs comma-separated, and then check against all of those.

Copy link
Member Author

@silverwind silverwind Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is there a way to obtain the current URL/Origin in this function? Do we need to pass *http.Request or some context down all the way to this function?

Copy link
Member Author

@silverwind silverwind Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the only way to make it work based on request URL is to determine the current HTTP request origin (from HTTP headers Host, X-Forwarded-Host, X-Forwarded-Protocol and more) into markup.RenderContext, which will be quite complicated.

It'll certainly be easier to let the user configure multiple server.ROOT_URL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this can be used:

func GuessCurrentAppURL(ctx context.Context) string {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants