@@ -153,37 +153,51 @@ internal static bool TryParseGameIdentifier(string input, EGameIdentifier defaul
153153 throw new InvalidEnumArgumentException ( nameof ( defaultType ) , ( int ) defaultType , typeof ( EGameIdentifier ) ) ;
154154 }
155155
156- if ( input . StartsWith ( "http" , StringComparison . OrdinalIgnoreCase ) && Uri . TryCreate ( input , UriKind . Absolute , out Uri ? uri ) && uri . Host . Equals ( ArchiWebHandler . SteamStoreURL . Host , StringComparison . OrdinalIgnoreCase ) ) {
157- string [ ] segments = uri . AbsolutePath . Split ( '/' , StringSplitOptions . RemoveEmptyEntries ) ;
156+ if ( Uri . TryCreate ( input , UriKind . Absolute , out Uri ? uri ) ) {
157+ switch ( uri . Scheme ) {
158+ case "http" or "https" when uri . Host . Equals ( ArchiWebHandler . SteamStoreURL . Host , StringComparison . OrdinalIgnoreCase ) :
159+ // Handle https://store.steampowered.com/<type>/<appID>
160+ string [ ] httpSegments = uri . AbsolutePath . Split ( '/' , 3 , StringSplitOptions . RemoveEmptyEntries ) ;
161+
162+ if ( httpSegments . Length < 2 ) {
163+ break ;
164+ }
165+
166+ type = httpSegments [ 0 ] . ToUpperInvariant ( ) switch {
167+ "APP" => EGameIdentifier . Application ,
168+ "SUB" => EGameIdentifier . Package ,
169+ _ => null
170+ } ;
171+
172+ if ( type == null ) {
173+ break ;
174+ }
158175
159- if ( segments . Length >= 2 ) {
160- type = segments [ 0 ] . ToUpperInvariant ( ) switch {
161- "APP" => EGameIdentifier . Application ,
162- "SUB" => EGameIdentifier . Package ,
163- _ => null
164- } ;
176+ if ( ! uint . TryParse ( httpSegments [ 1 ] , out uint pathNumericValue ) || ( pathNumericValue == 0 ) ) {
177+ type = null ;
178+
179+ break ;
180+ }
165181
166- if ( ( type != null ) && uint . TryParse ( segments [ 1 ] , out uint pathNumericValue ) && ( pathNumericValue > 0 ) ) {
167- value = segments [ 1 ] ;
182+ value = httpSegments [ 1 ] ;
168183
169184 return true ;
170- }
171- }
172- }
185+ case "steam" when uri . Host . Equals ( "launch" , StringComparison . OrdinalIgnoreCase ) :
186+ // Handle steam://launch/<appID>/ and steam://launch/<appID>/Dialog formats
187+ string [ ] steamSegments = uri . AbsolutePath . Split ( '/' , 2 , StringSplitOptions . RemoveEmptyEntries ) ;
173188
174- // Handle steam://launch/APPID/ and steam://launch/APPID/Dialog formats
175- if ( input . StartsWith ( "steam://launch/" , StringComparison . OrdinalIgnoreCase ) ) {
176- string launchPath = input [ "steam://launch/" . Length ..] ;
177- string [ ] launchSegments = launchPath . Split ( '/' , StringSplitOptions . RemoveEmptyEntries ) ;
189+ if ( ( steamSegments . Length < 1 ) || ! uint . TryParse ( steamSegments [ 0 ] , out uint launchAppId ) || ( launchAppId == 0 ) ) {
190+ break ;
191+ }
178192
179- if ( ( launchSegments . Length >= 1 ) && uint . TryParse ( launchSegments [ 0 ] , out uint launchAppId ) && ( launchAppId > 0 ) ) {
180- type = EGameIdentifier . Application ;
181- value = launchSegments [ 0 ] ;
193+ type = EGameIdentifier . Application ;
194+ value = steamSegments [ 0 ] ;
182195
183- return true ;
196+ return true ;
184197 }
185198 }
186199
200+ // Handle common ASF-specific format of <format>/<input>
187201 int slashIndex = input . IndexOf ( '/' , StringComparison . Ordinal ) ;
188202
189203 if ( ( slashIndex > 0 ) && ( input . Length > slashIndex + 1 ) ) {
0 commit comments