@@ -228,6 +228,35 @@ func Test_runBrowse(t *testing.T) {
228228 baseRepo : ghrepo .New ("bchadwic" , "LedZeppelinIV" ),
229229 expectedURL : "https://github.com/bchadwic/LedZeppelinIV/tree/trunk/main.go" ,
230230 },
231+ {
232+ name : "branch flag within dir" ,
233+ opts : BrowseOptions {
234+ Branch : "feature-123" ,
235+ PathFromRepoRoot : func () string { return "pkg/dir" },
236+ },
237+ baseRepo : ghrepo .New ("bstnc" , "yeepers" ),
238+ expectedURL : "https://github.com/bstnc/yeepers/tree/feature-123/" ,
239+ },
240+ {
241+ name : "branch flag within dir with ." ,
242+ opts : BrowseOptions {
243+ Branch : "feature-123" ,
244+ SelectorArg : "." ,
245+ PathFromRepoRoot : func () string { return "pkg/dir" },
246+ },
247+ baseRepo : ghrepo .New ("bstnc" , "yeepers" ),
248+ expectedURL : "https://github.com/bstnc/yeepers/tree/feature-123/pkg/dir" ,
249+ },
250+ {
251+ name : "branch flag within dir with dir" ,
252+ opts : BrowseOptions {
253+ Branch : "feature-123" ,
254+ SelectorArg : "inner/more" ,
255+ PathFromRepoRoot : func () string { return "pkg/dir" },
256+ },
257+ baseRepo : ghrepo .New ("bstnc" , "yeepers" ),
258+ expectedURL : "https://github.com/bstnc/yeepers/tree/feature-123/pkg/dir/inner/more" ,
259+ },
231260 {
232261 name : "file with line number" ,
233262 opts : BrowseOptions {
@@ -466,6 +495,11 @@ func Test_parsePathFromFileArg(t *testing.T) {
466495 fileArg : filepath .Join (".." , ".." , ".." ) + s + "" ,
467496 expectedPath : "" ,
468497 },
498+ {
499+ name : "empty fileArg" ,
500+ fileArg : "" ,
501+ expectedPath : "" ,
502+ },
469503 }
470504 for _ , tt := range tests {
471505 path , _ , _ , _ := parseFile (BrowseOptions {
0 commit comments