@@ -112,6 +112,7 @@ async def _clean_structural_nodes(
112112
113113def _extract_url_from_ax_node (
114114 ax_node : Union [AccessibilityNode , AXNode ],
115+ strip_slash : bool = False ,
115116) -> Optional [str ]:
116117 """Extracts URL from the properties of an Accessibility Node."""
117118 properties = ax_node .get ("properties" )
@@ -121,7 +122,10 @@ def _extract_url_from_ax_node(
121122 if prop .get ("name" ) == "url" :
122123 value_obj = prop .get ("value" )
123124 if value_obj and isinstance (value_obj .get ("value" ), str ):
124- return value_obj ["value" ].strip ()
125+ url_value = value_obj ["value" ].strip ()
126+ if strip_slash :
127+ url_value = url_value .strip ("/" )
128+ return url_value
125129 return None
126130
127131
@@ -283,12 +287,13 @@ async def get_accessibility_tree(
283287 #filter out nodes that link to current url
284288 try :
285289 current_url = page .url
290+ current_url = current_url .strip ("/" )
286291 filtered_nodes = []
287292 for node_data in nodes :
288293 if 'role' in node_data \
289294 and isinstance (node_data ['role' ], dict ) \
290295 and 'value' in node_data ['role' ] and node_data ['role' ]['value' ] == 'link' :
291- link_url = _extract_url_from_ax_node (node_data )
296+ link_url = _extract_url_from_ax_node (node_data , strip_slash = True )
292297
293298 if link_url and link_url != current_url :
294299 filtered_nodes .append (node_data )
0 commit comments