File tree 4 files changed +46
-1
lines changed
4 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const val DEFAULT_PORT: Int = 0
24
24
*/
25
25
class URLBuilder (
26
26
var protocol : URLProtocol = URLProtocol .HTTP ,
27
- var host : String = " localhost " ,
27
+ var host : String = originHost ,
28
28
var port : Int = DEFAULT_PORT ,
29
29
var user : String? = null ,
30
30
var password : String? = null ,
@@ -84,6 +84,13 @@ class URLBuilder(
84
84
companion object
85
85
}
86
86
87
+ /* *
88
+ * Hostname of current origin.
89
+ *
90
+ * It uses "localhost" for all platforms except js.
91
+ */
92
+ expect val URLBuilder .Companion .originHost: String
93
+
87
94
/* *
88
95
* Create a copy of this builder. Modifications in a copy is not reflected in the original instance and vise-versa.
89
96
*/
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3
+ */
4
+
5
+ package io.ktor.http
6
+
7
+ import io.ktor.util.*
8
+ import kotlin.browser.*
9
+
10
+ /* *
11
+ * Hostname of current origin.
12
+ *
13
+ * It uses "localhost" for all platforms except js.
14
+ */
15
+ actual val URLBuilder .Companion .originHost: String
16
+ get() = if (PlatformUtils .IS_BROWSER ) window.location.origin else " localhost"
Original file line number Diff line number Diff line change @@ -12,3 +12,11 @@ import java.net.*
12
12
operator fun Url.Companion.invoke (fullUrl : String ): Url = URLBuilder ().apply {
13
13
takeFrom(URI (fullUrl))
14
14
}.build()
15
+
16
+ /* *
17
+ * Hostname of current origin.
18
+ *
19
+ * It uses "localhost" for all platforms except js.
20
+ */
21
+ actual val URLBuilder .Companion .originHost: String
22
+ get() = " localhost"
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3
+ */
4
+
5
+ package io.ktor.http
6
+
7
+
8
+ /* *
9
+ * Hostname of current origin.
10
+ *
11
+ * It uses "localhost" for all platforms except js.
12
+ */
13
+ actual val URLBuilder .Companion .originHost: String
14
+ get() = " localhost"
You can’t perform that action at this time.
0 commit comments