Commit 3a9aea49 authored by Nick Stenning's avatar Nick Stenning

Make "/app" endpoints relative to serviceUrl

As reported by Donny Donovan from EJP, requests to "/app*" related
endpoints weren't correctly being constructed relative to the configured
"serviceUrl", which makes the client less portable.

This change removes a leading slash from the path supplied to the URL
constructor, ensuring that if "serviceUrl" is not at the root of a
domain, the "/app*" paths will still be correctly constructed.
parent 2f7d7d91
...@@ -56,7 +56,7 @@ function session($http, $resource, $rootScope, flash, raven, settings) { ...@@ -56,7 +56,7 @@ function session($http, $resource, $rootScope, flash, raven, settings) {
transformResponse: process, transformResponse: process,
withCredentials: true withCredentials: true
}); });
var endpoint = new URL('/app/:path', settings.serviceUrl).href; var endpoint = new URL('app/:path', settings.serviceUrl).href;
var resource = $resource(endpoint, {}, actions); var resource = $resource(endpoint, {}, actions);
// Blank initial model state // Blank initial model state
......
...@@ -30,7 +30,7 @@ describe('h:session', function () { ...@@ -30,7 +30,7 @@ describe('h:session', function () {
}; };
$provide.value('settings', { $provide.value('settings', {
serviceUrl: 'https://test.hypothes.is', serviceUrl: 'https://test.hypothes.is/root/',
}); });
$provide.value('flash', fakeFlash); $provide.value('flash', fakeFlash);
$provide.value('raven', fakeRaven); $provide.value('raven', fakeRaven);
...@@ -52,7 +52,7 @@ describe('h:session', function () { ...@@ -52,7 +52,7 @@ describe('h:session', function () {
// There's little point testing every single route here, as they're // There's little point testing every single route here, as they're
// declarative and ultimately we'd be testing ngResource. // declarative and ultimately we'd be testing ngResource.
describe('#login()', function () { describe('#login()', function () {
var url = 'https://test.hypothes.is/app?__formid__=login'; var url = 'https://test.hypothes.is/root/app?__formid__=login';
it('should send an HTTP POST to the action', function () { it('should send an HTTP POST to the action', function () {
$httpBackend.expectPOST(url, {code: 123}).respond({}); $httpBackend.expectPOST(url, {code: 123}).respond({});
...@@ -131,7 +131,7 @@ describe('h:session', function () { ...@@ -131,7 +131,7 @@ describe('h:session', function () {
}); });
describe('#load()', function () { describe('#load()', function () {
var url = 'https://test.hypothes.is/app'; var url = 'https://test.hypothes.is/root/app';
it('should fetch the session data', function () { it('should fetch the session data', function () {
$httpBackend.expectGET(url).respond({}); $httpBackend.expectGET(url).respond({});
...@@ -238,7 +238,7 @@ describe('h:session', function () { ...@@ -238,7 +238,7 @@ describe('h:session', function () {
}); });
describe('#dismiss_sidebar_tutorial()', function () { describe('#dismiss_sidebar_tutorial()', function () {
var url = 'https://test.hypothes.is/app/dismiss_sidebar_tutorial'; var url = 'https://test.hypothes.is/root/app/dismiss_sidebar_tutorial';
it('disables the tutorial for the user', function () { it('disables the tutorial for the user', function () {
$httpBackend.expectPOST(url).respond({}); $httpBackend.expectPOST(url).respond({});
session.dismiss_sidebar_tutorial(); session.dismiss_sidebar_tutorial();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment