mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Show API URL endpoints in user interface
This commit is contained in:
parent
b0442e0277
commit
b78172033f
11 changed files with 99 additions and 14 deletions
|
@ -55,7 +55,11 @@ func (c *Config) HasDebugMode() bool {
|
|||
|
||||
// BaseURL returns the application base URL.
|
||||
func (c *Config) BaseURL() string {
|
||||
return c.get("BASE_URL", defaultBaseURL)
|
||||
baseURL := c.get("BASE_URL", defaultBaseURL)
|
||||
if baseURL[len(baseURL)-1:] == "/" {
|
||||
baseURL = baseURL[:len(baseURL)-1]
|
||||
}
|
||||
return baseURL
|
||||
}
|
||||
|
||||
// DatabaseURL returns the database URL.
|
||||
|
|
39
config/config_test.go
Normal file
39
config/config_test.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2017 Frédéric Guillot. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetCustomBaseURL(t *testing.T) {
|
||||
os.Clearenv()
|
||||
os.Setenv("BASE_URL", "http://example.org")
|
||||
cfg := NewConfig()
|
||||
|
||||
if cfg.BaseURL() != "http://example.org" {
|
||||
t.Fatalf(`Unexpected base URL, got "%s"`, cfg.BaseURL())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCustomBaseURLWithTrailingSlash(t *testing.T) {
|
||||
os.Clearenv()
|
||||
os.Setenv("BASE_URL", "http://example.org/folder/")
|
||||
cfg := NewConfig()
|
||||
|
||||
if cfg.BaseURL() != "http://example.org/folder" {
|
||||
t.Fatalf(`Unexpected base URL, got "%s"`, cfg.BaseURL())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDefaultBaseURL(t *testing.T) {
|
||||
os.Clearenv()
|
||||
cfg := NewConfig()
|
||||
|
||||
if cfg.BaseURL() != "http://localhost" {
|
||||
t.Fatalf(`Unexpected base URL, got "%s"`, cfg.BaseURL())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue