项目作者: advanced-rest-client

项目描述 :
A module with logic and UI regions to support URL processing in Advanced REST Client application. It contains a logic to safely parse URLs with variables, build a URL input, or to enter any arbitrary URL with autosuggestions.
高级语言: JavaScript
项目地址: git://github.com/advanced-rest-client/arc-url.git
创建时间: 2020-10-03T09:18:26Z
项目社区:https://github.com/advanced-rest-client/arc-url

开源协议:Other

下载


Deprecated

This component is deprecated. Use @advanced-rest-client/app instead.


A module with logic an UI regions to support URL processing in Advanced REST Client application. It contains a logic to safely parse url with variables, build a URL input, or to enter any arbitrary URL with autosuggestions.

Build Status

Usage

Installation

  1. npm install --save @advanced-rest-client/arc-url

UrlParser class

A URL parsing library for Advanced REST Client.

It provides an interface similar to the URL class but it is more relax in terms of input validity. It means that it won’t throw an error when the URL is invalid. This allows to use the library in request editors.

Example

  1. import { UrlParser } from '@advanced-rest-client/arc-url';
  2. const parser = new UrlParser('https:///path-with-missing-host?qury=value#string');
  3. console.log(parser.protocol);
  4. console.log(parser.host);
  5. console.log(parser.path);
  6. console.log(parser.searchParams);
  7. console.log(parser.anchor);

web-url-input

An element to render a dialog to enter an URL with auto hints.

Examples

  1. <html>
  2. <head>
  3. <script type="module">
  4. import '@advanced-rest-client/arc-url/web-url-input.js';
  5. import '@advanced-rest-client/arc-models/url-history-model.js';
  6. </script>
  7. </head>
  8. <body>
  9. <url-history-model></url-history-model>
  10. <web-url-input></web-url-input>
  11. </body>
  12. </html>
  1. import { LitElement, html } from 'lit-element';
  2. import '@advanced-rest-client/arc-url/web-url-input.js';
  3. import '@advanced-rest-client/arc-models/url-history-model.js';
  4. class SampleElement extends LitElement {
  5. render() {
  6. return html`
  7. <url-history-model></url-history-model>
  8. <web-url-input @open="${this.openHandler}"></web-url-input>
  9. `;
  10. }
  11. openHandler(e) {
  12. console.log(e.target.value);
  13. }
  14. }
  15. customElements.define('sample-element', SampleElement);

url-input-editor

A HTTP request URL editor for a HTTP request editor.

URL editor example

  1. import { LitElement, html } from 'lit-element';
  2. import '@advanced-rest-client/arc-url/url-input-editor.js';
  3. import '@advanced-rest-client/arc-models/url-history-model.js';
  4. class SampleElement extends LitElement {
  5. render() {
  6. return html`
  7. <url-history-model></url-history-model>
  8. <url-input-editor
  9. .value="${this.url}"
  10. @change="${this.valueChanged}"
  11. ></url-input-editor>
  12. `;
  13. }
  14. valueChanged(e) {
  15. this.url = e.target.value;
  16. }
  17. }
  18. customElements.define('sample-element', SampleElement);

Development

  1. git clone https://github.com/advanced-rest-client/arc-url
  2. cd arc-url
  3. npm install

Running the tests

  1. npm test