@@ -1267,22 +1267,29 @@ bool CLIENT_STATE::poll_slow_events() {
12671267#endif // ifndef SIM
12681268
12691269// Find the project with the given master_url.
1270- // Ignore differences in protocol, case, and trailing /
1270+ // Ignore differences in protocol, case, leading 'www.', and trailing /
1271+ // (the URL could come from an account manager,
1272+ // with differences from the real URL)
12711273//
12721274PROJECT* CLIENT_STATE::lookup_project (const char * master_url) {
12731275 char buf[256 ];
12741276
12751277 safe_strcpy (buf, master_url);
12761278 canonicalize_master_url (buf, sizeof (buf));
1277- char * p = strstr (buf, " //" );
1279+ const char * p = strstr (buf, " //" );
12781280 if (!p) return NULL ;
1281+ p += 2 ;
1282+ if (strcasestr (p, " www." ) == p) p += 4 ;
1283+ strcpy (buf, p);
12791284
1280- for (unsigned int i= 0 ; i< projects. size (); i++ ) {
1281- char * q = strstr (projects[i] ->master_url , " //" );
1285+ for (PROJECT *project: projects) {
1286+ const char * q = strstr (project ->master_url , " //" );
12821287 if (!q) continue ;
1283- if (!strcasecmp (p, q)) {
1288+ q += 2 ;
1289+ if (strcasestr (q, " www." ) == q) q += 4 ;
1290+ if (!strcasecmp (buf, q)) {
12841291 // note: canonicalize_master_url() doesn't lower-case
1285- return projects[i] ;
1292+ return project ;
12861293 }
12871294 }
12881295 return 0 ;
0 commit comments