@@ -69,6 +69,84 @@ describe('VMess and VLESS parser coverage', function () {
6969 } ) ;
7070 } ) ;
7171
72+ it ( 'prefers fragment comments over internal V2rayN vmess names' , function ( ) {
73+ const share = Base64 . encode (
74+ JSON . stringify ( {
75+ v : '2' ,
76+ ps : 'VMess WS Fragment' ,
77+ add : 'vmess-fragment.example.com' ,
78+ port : '443' ,
79+ id : UUID ,
80+ aid : '0' ,
81+ scy : 'none' ,
82+ net : 'ws' ,
83+ host : 'fragment.example.com' ,
84+ path : '/fragment?ed=2560' ,
85+ tls : 'tls' ,
86+ sni : 'sni.fragment.example.com' ,
87+ fp : 'chrome' ,
88+ } ) ,
89+ ) ;
90+ const proxy = parseOne ( `vmess://${ share } #Outer%20Fragment%20Remark` ) ;
91+
92+ expectSubset ( proxy , {
93+ type : 'vmess' ,
94+ name : 'Outer Fragment Remark' ,
95+ server : 'vmess-fragment.example.com' ,
96+ port : 443 ,
97+ uuid : UUID ,
98+ alterId : 0 ,
99+ cipher : 'none' ,
100+ tls : true ,
101+ sni : 'sni.fragment.example.com' ,
102+ 'client-fingerprint' : 'chrome' ,
103+ network : 'ws' ,
104+ 'ws-opts' : {
105+ path : '/fragment?ed=2560' ,
106+ headers : {
107+ Host : 'fragment.example.com' ,
108+ } ,
109+ } ,
110+ } ) ;
111+ } ) ;
112+
113+ it ( 'keeps the full vmess fragment comment after the first hash' , function ( ) {
114+ const share = Base64 . encode (
115+ JSON . stringify ( {
116+ v : '2' ,
117+ ps : 'VMess WS Fragment Full' ,
118+ add : 'vmess-fragment-full.example.com' ,
119+ port : '443' ,
120+ id : UUID ,
121+ aid : '0' ,
122+ scy : 'auto' ,
123+ net : 'ws' ,
124+ host : 'fragment-full.example.com' ,
125+ path : '/fragment-full' ,
126+ tls : 'tls' ,
127+ } ) ,
128+ ) ;
129+ const proxy = parseOne ( `vmess://${ share } #Outer%20Fragment#Remark` ) ;
130+
131+ expectSubset ( proxy , {
132+ type : 'vmess' ,
133+ name : 'Outer Fragment#Remark' ,
134+ server : 'vmess-fragment-full.example.com' ,
135+ port : 443 ,
136+ uuid : UUID ,
137+ alterId : 0 ,
138+ cipher : 'auto' ,
139+ tls : true ,
140+ network : 'ws' ,
141+ 'ws-opts' : {
142+ path : '/fragment-full' ,
143+ headers : {
144+ Host : 'fragment-full.example.com' ,
145+ } ,
146+ } ,
147+ } ) ;
148+ } ) ;
149+
72150 it ( 'parses V2rayN http shares and normalizes http paths' , function ( ) {
73151 const share = Base64 . encode (
74152 JSON . stringify ( {
@@ -257,6 +335,34 @@ describe('VMess and VLESS parser coverage', function () {
257335 } ) ;
258336 } ) ;
259337
338+ it ( 'keeps the full vless fragment comment after the first hash' , function ( ) {
339+ const proxy = parseOne (
340+ `vless://${ UUID } @vless-ws.example.com:443?type=ws&security=tls&sni=sni.example.com&host=cdn.example.com&path=%2Fws&allowInsecure=1&fp=chrome&alpn=h2#VLESS%20Outer#Remark` ,
341+ ) ;
342+
343+ expectSubset ( proxy , {
344+ type : 'vless' ,
345+ name : 'VLESS Outer#Remark' ,
346+ server : 'vless-ws.example.com' ,
347+ port : 443 ,
348+ uuid : UUID ,
349+ tls : true ,
350+ sni : 'sni.example.com' ,
351+ 'skip-cert-verify' : true ,
352+ 'client-fingerprint' : 'chrome' ,
353+ alpn : [ 'h2' ] ,
354+ udp : true ,
355+ xudp : true ,
356+ network : 'ws' ,
357+ 'ws-opts' : {
358+ path : '/ws' ,
359+ headers : {
360+ Host : 'cdn.example.com' ,
361+ } ,
362+ } ,
363+ } ) ;
364+ } ) ;
365+
260366 it ( 'parses websocket VLESS shares with packet encoding and early data' , function ( ) {
261367 const proxy = parseOne (
262368 `vless://${ UUID } @vless-ws.example.com:443?type=ws&security=tls&host=cdn.example.com&path=%2Fws&packetEncoding=packet&ed=2048&eh=X-Data#VLESS%20WS%20Early` ,
0 commit comments