getBaseURL.js 460 B

12345678910111213141516
  1. var staticLocation = require('./staticLocation')
  2. var helperGetLocatOrigin = require('./helperGetLocatOrigin')
  3. var lastIndexOf = require('./lastIndexOf')
  4. function getBaseURL () {
  5. if (staticLocation) {
  6. var pathname = staticLocation.pathname
  7. var lastIndex = lastIndexOf(pathname, '/') + 1
  8. return helperGetLocatOrigin() + (lastIndex === pathname.length ? pathname : pathname.substring(0, lastIndex))
  9. }
  10. return ''
  11. }
  12. module.exports = getBaseURL