From 0212544da2e2a1af8508d6ce616b54679c7ab3bb Mon Sep 17 00:00:00 2001
From: chrisgarrity <chrisg@media.mit.edu>
Date: Wed, 21 Jun 2017 13:45:41 -0400
Subject: [PATCH] fix generated urls

use url.resolve instead of just path. Path takes out the double slash on the `https://`
---
 .gitignore           | 3 ++-
 bin/build-www-json   | 7 ++++---
 resources/index.html | 3 ++-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1bd6ef0..3aed1a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,5 @@
 
 # NPM
 /node_modules
-npm-*
\ No newline at end of file
+npm-*
+localized-urls.json
diff --git a/bin/build-www-json b/bin/build-www-json
index 0bbdaf3..47fc9c3 100755
--- a/bin/build-www-json
+++ b/bin/build-www-json
@@ -24,6 +24,7 @@
 
 var fs = require('fs');
 var path = require('path');
+var url = require('url');
 var merge = require('lodash.merge');
 
 // -----------------------------------------------------------------------------
@@ -47,12 +48,12 @@ const allFilesSync = (dir, fileList = []) => {
 };
 
 const fileId = (dir, file) => {
-    return dir + '.' + path.parse(file).name + "Link" ;
+    return dir + '.' + path.parse(file).name + 'Link';
 };
 
 const bucketPath = (resource, locale, file) => {
     const bucketRoot = 'https://resources.scratch.mit.edu/www/';
-    return path.join(bucketRoot, resource, locale, file);
+    return url.resolve(bucketRoot, path.join(resource, locale, file));
 };
 
 const localeURL = (resource, locale, file) => {
@@ -118,4 +119,4 @@ try {
 
 var allFiles = allFilesSync(inputsDir);
 var output = parseFileList(allFiles);
-writeJsonFile(outputDir, output);
\ No newline at end of file
+writeJsonFile(outputDir, output);
diff --git a/resources/index.html b/resources/index.html
index 1589256..8a65932 100644
--- a/resources/index.html
+++ b/resources/index.html
@@ -33,7 +33,8 @@
     // var BUCKET_NAME = 'scratch-resources';
     var BUCKET_URL = 'https://scratch-resources.s3.amazonaws.com';
     var BUCKET_WEBSITE_URL = 'https://resources.scratch.mit.edu';
-    var S3B_ROOT_DIR = 'source/';
+    //var S3B_ROOT_DIR = 'source/'; //use this to restrict browsing to the source folder
+    var S3B_ROOT_DIR = '';
     var S3B_SORT = 'A2Z';
     // var EXCLUDE_FILE = '.DS_Store';
     // var AUTO_TITLE = true;