File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -80,4 +80,10 @@ describe('Api', () => {
8080 const api = new Api ( SERVER_URL , TEST_CLIENT , TEST_DEVICE ) ;
8181 expect ( api . basePath ) . toBe ( SERVER_URL ) ;
8282 } ) ;
83+
84+ it ( 'should return the correct uri' , ( ) => {
85+ const api = new Api ( SERVER_URL , TEST_CLIENT , TEST_DEVICE ) ;
86+ const uri = api . getUri ( '/api/url' , { param1 : 'bar' , param2 : 'baz 123;xyz' } ) ;
87+ expect ( uri ) . toBe ( `${ SERVER_URL } /api/url?param1=bar¶m2=baz+123%3Bxyz` ) ;
88+ } ) ;
8389} ) ;
Original file line number Diff line number Diff line change @@ -64,6 +64,20 @@ export class Api {
6464 } ) ;
6565 }
6666
67+ /**
68+ * Gets a full URI for a relative URL to the Jellyfin server for a given SDK Api instance.
69+ * @param url The relative URL.
70+ * @param params Any URL parameters.
71+ * @returns The complete URI with protocol, host, and base URL (if any).
72+ */
73+ getUri ( url : string , params ?: object ) {
74+ return this . axiosInstance . getUri ( {
75+ baseURL : this . basePath ,
76+ url,
77+ params
78+ } ) ;
79+ }
80+
6781 /**
6882 * Convenience method for logging out and updating the internal state.
6983 */
You can’t perform that action at this time.
0 commit comments