azure-ad-b2c / html-templates

67 stars 68 forks source link

Consider stripping https://login.microsoft.com from templates resource urls #1

Open KevinCathcart opened 3 years ago

KevinCathcart commented 3 years ago

I think the result (local resources use domain relative paths like "/templates/src/..." is probably more useful than having absolute urls that point at "https://login.microsoft.com/template/src" and don't resolve.

Alternatively, use an absolute url that is clearly a placeholder, like https://localhost/ or https://static.contoso.com/.

The following trivial patch, and rerunning would handle this.

                     // Change the directory name for the legacy template
                     if (htmlFileURI.IndexOf("templates/") < 0)
                     {
                         reply = reply.Replace("https://login.microsoftonline.com/static/tenant/default/img/",
                                       "https://login.microsoftonline.com/static/tenant/templates/classic/img/");
                     }

+                    // Use domain relative urls.
+                    reply = reply.Replace("https://login.microsoftonline.com/", "/");
+
                     // Remove the static tenant
                     reply = reply.Replace("/static/tenant/", "/");

                     // Add the src folder to the path
                     reply = reply.Replace("/templates/", "/templates/src/");

                     File.WriteAllText(localpath, reply);

Thoughts?