Skip to content

Commit f36fba2

Browse files
authored
fix: revert: use CRC32 to shorten app subdomain
This reverts commit 0e28397.
1 parent b039dc6 commit f36fba2

File tree

4 files changed

+6
-24
lines changed

4 files changed

+6
-24
lines changed

coderd/httpapi/url.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package httpapi
22

33
import (
44
"fmt"
5-
"hash/crc32"
65
"net"
76
"regexp"
87
"strings"
@@ -19,8 +18,6 @@ var (
1918
nameRegex))
2019

2120
validHostnameLabelRegex = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)
22-
23-
crcTable = crc32.MakeTable(crc32.IEEE)
2421
)
2522

2623
// ApplicationURL is a parsed application URL hostname.
@@ -42,12 +39,7 @@ func (a ApplicationURL) String() string {
4239
_, _ = appURL.WriteString(a.WorkspaceName)
4340
_, _ = appURL.WriteString("--")
4441
_, _ = appURL.WriteString(a.Username)
45-
hostname := appURL.String()
46-
47-
if len(hostname) < 64 { // max length for the subdomain level
48-
return hostname
49-
}
50-
return fmt.Sprintf("app-%08x", crc32.Checksum([]byte(hostname), crcTable))
42+
return appURL.String()
5143
}
5244

5345
// ParseSubdomainAppURL parses an ApplicationURL from the given subdomain. If

coderd/httpapi/url_test.go

-10
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ func TestApplicationURLString(t *testing.T) {
4242
},
4343
Expected: "8080--agent--workspace--user",
4444
},
45-
{
46-
Name: "LongAppName",
47-
URL: httpapi.ApplicationURL{
48-
AppSlugOrPort: "0123456789012345678901234567890123456789",
49-
AgentName: "agent",
50-
WorkspaceName: "workspace",
51-
Username: "user",
52-
},
53-
Expected: "app-90667f72",
54-
},
5545
}
5646

5747
for _, c := range testCases {

coderd/workspaceapps/apptest/apptest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
13531353
}, testutil.WaitLong, testutil.IntervalFast, "stats not reported")
13541354

13551355
assert.Equal(t, workspaceapps.AccessMethodPath, stats[0].AccessMethod)
1356-
assert.Equal(t, proxyTestAppNameOwner, stats[0].SlugOrPort)
1356+
assert.Equal(t, "test-app-owner", stats[0].SlugOrPort)
13571357
assert.Equal(t, 1, stats[0].Requests)
13581358
})
13591359
}

coderd/workspaceapps/apptest/setup.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ import (
3232

3333
const (
3434
proxyTestAgentName = "agent-name"
35-
proxyTestAppNameFake = "taf"
36-
proxyTestAppNameOwner = "tao"
37-
proxyTestAppNameAuthenticated = "taa"
38-
proxyTestAppNamePublic = "tap"
35+
proxyTestAppNameFake = "test-app-fake"
36+
proxyTestAppNameOwner = "test-app-owner"
37+
proxyTestAppNameAuthenticated = "test-app-authenticated"
38+
proxyTestAppNamePublic = "test-app-public"
3939
proxyTestAppQuery = "query=true"
4040
proxyTestAppBody = "hello world from apps test"
4141

0 commit comments

Comments
 (0)