Repository: cli/cli
File: pkg/cmd/search/code/code_test.go (Go)

Code before:
					URLFunc: func(query search.Query) string {
						return "https://github.com/search?type=code&q=map+repo%3Acli%2Fcli"
					},
				},
				WebMode: true,
			},
			wantBrowse: "https://github.com/search?type=code&q=map+repo%3Acli%2Fcli",
		},
		{
			name: "converts filename and extension qualifiers for github.com web search",
			opts: &CodeOptions{
				Config: func() (gh.Config, error) { return config.NewBlankConfig(), nil },
				Query: search.Query{
					Keywords: []string{"map"},
					Kind:     "code",
					Limit:    30,
					Qualifiers: search.Qualifiers{
						Filename:  "testing",
						Extension: "go",
					},
				},
				Searcher: search.NewSearcher(nil, "github.com"),
				WebMode:  true,
			},
			wantBrowse: "https://github.com/search?q=map+path%3Atesting.go&type=code",
		},
		{
			name: "does not convert filename and extension qualifiers for GHES web search",
			opts: &CodeOptions{
				Config: func() (gh.Config, error) {
					cfg := &ghmock.ConfigMock{
						AuthenticationFunc: func() gh.AuthConfig {
							authCfg := &config.AuthConfig{}
							authCfg.SetDefaultHost("example.com", "GH_HOST")
							return authCfg
						},
					}
					return cfg, nil
				},
				Query: search.Query{
					Keywords: []string{"map"},
					Kind:     "code",
					Limit:    30,
					Qualifiers: search.Qualifiers{
						Filename:  "testing",
						Extension: "go",
					},
				},
				Searcher: search.NewSearcher(nil, "example.com"),
				WebMode:  true,
			},

Review comment (suggestion):
Can you please also add a similar test case where the `--extension` value is prefixed with a dot `.`? I want to ensure we cover that path as well.

Code after:
					URLFunc: func(query search.Query) string {
						return "https://github.com/search?type=code&q=map+repo%3Acli%2Fcli"
					},
				},
				WebMode: true,
			},
			wantBrowse: "https://github.com/search?type=code&q=map+repo%3Acli%2Fcli",
		},
		{
			name: "converts filename and extension qualifiers for github.com web search",
			opts: &CodeOptions{
				Config: func() (gh.Config, error) { return config.NewBlankConfig(), nil },
				Query: search.Query{
					Keywords: []string{"map"},
					Kind:     "code",
					Limit:    30,
					Qualifiers: search.Qualifiers{
						Filename:  "testing",
						Extension: "go",
					},
				},
				Searcher: search.NewSearcher(nil, "github.com"),
				WebMode:  true,
			},
			wantBrowse: "https://github.com/search?q=map+path%3Atesting.go&type=code",
		},
		{
			name: "properly handles extension with dot prefix when converting to path qualifier",
			opts: &CodeOptions{
				Config: func() (gh.Config, error) { return config.NewBlankConfig(), nil },
				Query: search.Query{
					Keywords: []string{"map"},
					Kind:     "code",
					Limit:    30,
					Qualifiers: search.Qualifiers{
						Filename:  "testing",
						Extension: ".cpp",
					},
				},
				Searcher: search.NewSearcher(nil, "github.com"),
				WebMode:  true,
			},
			wantBrowse: "https://github.com/search?q=map+path%3Atesting.cpp&type=code",
		},
		{
			name: "does not convert filename and extension qualifiers for GHES web search",
			opts: &CodeOptions{
				Config: func() (gh.Config, error) {
					cfg := &ghmock.ConfigMock{
						AuthenticationFunc: func() gh.AuthConfig {
							authCfg := &config.AuthConfig{}