@@ -58,16 +58,20 @@ describe('normalizeNameAndTitle', () => {
5858} ) ;
5959
6060describe ( 'CLEAR_COORDINATES_REGEX' , ( ) => {
61- test ( 'captures lat/lon plus optional zoom and name from a clear-text path' , ( ) => {
61+ test ( 'captures lat/lon and an optional / name from a clear-text path' , ( ) => {
6262 expect ( '/53.9,27.56' . match ( CLEAR_COORDINATES_REGEX ) ?. groups ) . toMatchObject ( { lat : '53.9' , lon : '27.56' } ) ;
63- expect ( '/53.9,27.56,15, Minsk' . match ( CLEAR_COORDINATES_REGEX ) ?. groups ) . toMatchObject ( {
63+ expect ( '/53.9,27.56/ Minsk' . match ( CLEAR_COORDINATES_REGEX ) ?. groups ) . toMatchObject ( {
6464 lat : '53.9' ,
6565 lon : '27.56' ,
66- zoom : '15' ,
6766 name : 'Minsk' ,
6867 } ) ;
6968 } ) ;
7069
70+ test ( 'keeps a digit-initial name intact (there is no in-path zoom to swallow it)' , ( ) => {
71+ expect ( '/48.85,2.29/7-Eleven' . match ( CLEAR_COORDINATES_REGEX ) ?. groups ?. name ) . toBe ( '7-Eleven' ) ;
72+ expect ( '/48.85,2.29/24-hour-shop' . match ( CLEAR_COORDINATES_REGEX ) ?. groups ?. name ) . toBe ( '24-hour-shop' ) ;
73+ } ) ;
74+
7175 test ( 'does not match an encoded ge0 payload, so it falls through to the binary decoder' , ( ) => {
7276 expect ( '/B4srhdHVVt' . match ( CLEAR_COORDINATES_REGEX ) ) . toBeNull ( ) ;
7377 } ) ;
@@ -98,7 +102,7 @@ describe('onGe0Decode — end to end', () => {
98102 } ) ;
99103
100104 test ( 'renders clear-text coordinates' , async ( ) => {
101- const html = await ( await onGe0Decode ( TEMPLATE , 'https://omaps.app/53.9,27.56,15, Minsk' ) ) . text ( ) ;
105+ const html = await ( await onGe0Decode ( TEMPLATE , 'https://omaps.app/53.9,27.56/ Minsk?z=15 ' ) ) . text ( ) ;
102106 expect ( html ) . toContain ( '<coords>53.9,27.56@15</coords>' ) ;
103107 expect ( html ) . toContain ( '<name>Minsk</name>' ) ;
104108 } ) ;
@@ -109,7 +113,7 @@ describe('onGe0Decode — end to end', () => {
109113 } ) ;
110114
111115 test ( 'HTML-escapes the pin name of a clear-text link to prevent XSS' , async ( ) => {
112- const html = await ( await onGe0Decode ( TEMPLATE , 'https://omaps.app/12.3,45.6,15, <script>alert(1)</script>' ) ) . text ( ) ;
116+ const html = await ( await onGe0Decode ( TEMPLATE , 'https://omaps.app/12.3,45.6/ <script>alert(1)</script>' ) ) . text ( ) ;
113117 expect ( html ) . toContain ( '<name><script>alert(1)</script></name>' ) ;
114118 expect ( html ) . not . toContain ( '<script>alert(1)</script>' ) ;
115119 } ) ;
@@ -139,14 +143,13 @@ describe('onGe0Decode — end to end', () => {
139143 expect ( html ) . toContain ( '<coords>53.9,27.56@16</coords>' ) ;
140144 } ) ;
141145
142- test ( '?z= takes precedence over a legacy path zoom' , async ( ) => {
143- const html = await ( await onGe0Decode ( TEMPLATE , 'https://omaps.app/53.9,27.56,15?z=16' ) ) . text ( ) ;
144- expect ( html ) . toContain ( '<coords>53.9,27.56@16</coords>' ) ;
146+ test ( 'a digit-initial name is not mistaken for a zoom' , async ( ) => {
147+ const html = await ( await onGe0Decode ( TEMPLATE , 'https://omaps.app/48.85,2.29/7-Eleven?z=16' ) ) . text ( ) ;
148+ expect ( html ) . toContain ( '<coords>48.85,2.29@16</coords>' ) ;
149+ expect ( html ) . toContain ( '<name>7-Eleven</name>' ) ;
145150 } ) ;
146151
147- test ( '?z= is optional — falls back to the path zoom, then the default' , async ( ) => {
148- const path = await ( await onGe0Decode ( TEMPLATE , 'https://omaps.app/53.9,27.56,15' ) ) . text ( ) ;
149- expect ( path ) . toContain ( '<coords>53.9,27.56@15</coords>' ) ;
152+ test ( '?z= is optional — a bare link falls back to the default zoom' , async ( ) => {
150153 const bare = await ( await onGe0Decode ( TEMPLATE , 'https://omaps.app/53.9,27.56' ) ) . text ( ) ;
151154 expect ( bare ) . toContain ( '<coords>53.9,27.56@14</coords>' ) ;
152155 } ) ;
0 commit comments