Prepending relative urls with '/'

This commit is contained in:
Pawel Kadluczka 2017-09-15 15:12:36 -07:00
parent b40578b89b
commit 982ac32fea
3 changed files with 34 additions and 1 deletions

View File

@ -173,6 +173,10 @@ export class HttpConnection implements IConnection {
? `${window.document.location.protocol}//${(parser.host || window.document.location.host)}`
: `${parser.protocol}//${parser.host}`;
if (!url || url[0] != '/') {
url = '/' + url;
}
let normalizedUrl = baseUrl + url;
this.logger.log(LogLevel.Information, `Normalizing '${url}' to '${normalizedUrl}'`);
return normalizedUrl;

View File

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:60249/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Microsoft.AspNetCore.SignalR.Test.Server": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5000/"
}
}
}

View File

@ -34,7 +34,9 @@ describe('connection', function () {
eachTransport(function (transportType) {
it("over " + signalR.TransportType[transportType] + " can send and receive messages", function (done) {
var message = "Hello World!";
var connection = new signalR.HttpConnection(ECHOENDPOINT_URL, {
// the url should be resolved relative to the document.location.host
// and the leading '/' should be automatically added to the url
var connection = new signalR.HttpConnection("echo", {
transport: transportType,
logging: signalR.LogLevel.Trace
});