Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
Feature: Allow to specify a pathname only URL for swagger spec (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
cguedes committed Nov 6, 2016
1 parent fc7d6b8 commit 2686b71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sampleapp/basepath/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import APIExplorer from './../../src'
import AddLinksPlugin from './plugin'

APIExplorer
.addAPI('petstore', 'swagger2', `${window.location.protocol}//${window.location.host}/sampleapp/petstore/petstore.json`, c => {
.addAPI('petstore', 'swagger2', `/sampleapp/petstore/petstore.json`, c => {
c.useProxy(true)
})
.addPlugin(AddLinksPlugin)
Expand Down
7 changes: 7 additions & 0 deletions src/infrastructure/Url.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ const URI_PROTOCOL_REGEX = /([a-z]+):\/\//

class Url {
constructor (url) {
if (url.startsWith('/')) {
console.log('Converting pathname only URL to URL with protocol and host.')
console.log(`Current url: ${url}`)
url = `${window.location.protocol}//${window.location.host}${url}`
console.log(`Final url: ${url}`)
}

this.url = ''
this.queryString = ''
this.useProxy = false
Expand Down

0 comments on commit 2686b71

Please sign in to comment.