VulcanJS / Vulcan

🌋 A toolkit to quickly build apps with React, GraphQL & Meteor
http://vulcanjs.org
MIT License
7.98k stars 1.88k forks source link

Problem with Utils.getSiteUrl() #2095

Closed ErikDakoda closed 5 years ago

ErikDakoda commented 5 years ago

All paths in routes start with a slash. For example in vulcan-admin/lib/modules/routes.js:

addRoute({ 
  name: 'admin', 
  path: '/admin', 
  component: () => getDynamicComponent(import('../components/AdminHome.jsx'))
});

However Utils.getSiteUrl() in vulcan-lib/lib/modules/utils.js adds a slash at the end of all root URLs.

So when you combine the two to form a full URL, in an email, for example {{siteUrl}}{{myPage}}, you end up with a double slash.

In fact I have noticed that in the vulcan code base the last character is constantly being sliced off the result of Utils.getSiteUrl(). Shouldn't we fix this?

SachaG commented 5 years ago

Maybe we need to add a makeAbsolute() util that takes a path and makes it absolute, adding a slash if need be?

ErikDakoda commented 5 years ago

In addition to Utils.getSiteUrl(), there is now a Utils.getRootUrl() function that returns the siteUrl setting without a slash.

https://github.com/VulcanJS/Vulcan/pull/2294