UNPKG

ng-tiny-url

Version:
53 lines (47 loc) 1.61 kB
import { ɵɵdefineInjectable, ɵɵinject, Injectable, NgModule } from '@angular/core'; import { HttpHeaders, HttpClient, HttpClientModule } from '@angular/common/http'; import { map } from 'rxjs/operators'; class NgTinyUrlService { constructor(http) { this.http = http; this.headers = new HttpHeaders({ 'Content-Type': 'application/json' }); } shorten(url, alias) { let extras = ''; if (alias) { extras = `&alias=${encodeURIComponent(alias)}`; } return this.http.get('https://tinyurl.com/api-create.php?url=' + encodeURIComponent(url) + extras, { headers: this.headers, responseType: 'text' }).pipe(map(res => res.toString())); } } NgTinyUrlService.ɵprov = ɵɵdefineInjectable({ factory: function NgTinyUrlService_Factory() { return new NgTinyUrlService(ɵɵinject(HttpClient)); }, token: NgTinyUrlService, providedIn: "root" }); NgTinyUrlService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; NgTinyUrlService.ctorParameters = () => [ { type: HttpClient } ]; class NgTinyUrlModule { } NgTinyUrlModule.decorators = [ { type: NgModule, args: [{ declarations: [], imports: [ HttpClientModule ], exports: [] },] } ]; /* * Public API Surface of ng-tiny-url */ /** * Generated bundle index. Do not edit. */ export { NgTinyUrlModule, NgTinyUrlService }; //# sourceMappingURL=ng-tiny-url.js.map