File tree 3 files changed +31
-1
lines changed
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ var projectLocalOpenCmd = &console.Command{
54
54
}
55
55
host := fmt .Sprintf ("127.0.0.1:%d" , pidFile .Port )
56
56
if proxyConf , err := proxy .Load (util .GetHomeDir ()); err == nil {
57
- domains := proxyConf .GetDomains (projectDir )
57
+ domains := proxyConf .GetReachableDomains (projectDir )
58
58
if len (domains ) > 0 {
59
59
host = domains [0 ]
60
60
}
Original file line number Diff line number Diff line change @@ -158,6 +158,23 @@ func (c *Config) GetDomains(dir string) []string {
158
158
return domains
159
159
}
160
160
161
+ func (c * Config ) GetReachableDomains (dir string ) []string {
162
+ c .mu .Lock ()
163
+ defer c .mu .Unlock ()
164
+ domains := []string {}
165
+ for domain , d := range c .domains {
166
+ // domain is defined using a wildcard: we don't know the exact domain,
167
+ // so we can't use it directly as-is to reach the project
168
+ if strings .Contains (domain , "*" ) {
169
+ continue
170
+ }
171
+ if d == dir {
172
+ domains = append (domains , domain + "." + c .TLD )
173
+ }
174
+ }
175
+ return domains
176
+ }
177
+
161
178
func (c * Config ) SetDomains (domains map [string ]string ) {
162
179
c .mu .Lock ()
163
180
c .domains = domains
Original file line number Diff line number Diff line change @@ -43,3 +43,16 @@ func (s *ProxySuite) TestGetDir(c *C) {
43
43
c .Assert (p .GetDir ("foo.symfony.com" ), Equals , "any_symfony_com" )
44
44
c .Assert (p .GetDir ("foo.live.symfony.com" ), Equals , "any_live_symfony_com" )
45
45
}
46
+
47
+ func (s * ProxySuite ) TestGetReachableDomains (c * C ) {
48
+ p := & Config {
49
+ TLD : "wip" ,
50
+ domains : map [string ]string {
51
+ "*.symfony" : "symfony_com" ,
52
+ "symfony" : "symfony_com" ,
53
+ "custom.*.symfony" : "symfony_com" ,
54
+ "*.live.symfony" : "symfony_com" ,
55
+ },
56
+ }
57
+ c .Assert (p .GetReachableDomains ("symfony_com" ), DeepEquals , []string {"symfony.wip" })
58
+ }
You can’t perform that action at this time.
0 commit comments