├── .editorconfig ├── .ember-cli ├── .eslintignore ├── .eslintrc.js ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .npmignore ├── .prettierignore ├── .prettierrc.js ├── .template-lintrc.js ├── .watchmanconfig ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── addon ├── .gitkeep ├── helpers │ └── root-url.js └── services │ └── root-url.js ├── app ├── .gitkeep ├── helpers │ └── root-url.js └── services │ └── root-url.js ├── config ├── ember-try.js └── environment.js ├── ember-cli-build.js ├── index.js ├── package.json ├── testem.js ├── tests ├── dummy │ ├── app │ │ ├── app.js │ │ ├── components │ │ │ └── .gitkeep │ │ ├── controllers │ │ │ └── .gitkeep │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── index.html │ │ ├── models │ │ │ └── .gitkeep │ │ ├── router.js │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ └── templates │ │ │ └── application.hbs │ ├── config │ │ ├── ember-cli-update.json │ │ ├── environment.js │ │ ├── optional-features.json │ │ └── targets.js │ └── public │ │ ├── example.png │ │ └── robots.txt ├── helpers │ └── .gitkeep ├── index.html ├── integration │ ├── .gitkeep │ └── helpers │ │ └── root-url-test.js ├── test-helper.js └── unit │ ├── .gitkeep │ └── services │ └── root-url-test.js ├── vendor └── .gitkeep └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.hbs] 16 | insert_final_newline = false 17 | 18 | [*.{diff,md}] 19 | trim_trailing_whitespace = false 20 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | /vendor/ 4 | 5 | # compiled output 6 | /dist/ 7 | /tmp/ 8 | 9 | # dependencies 10 | /bower_components/ 11 | /node_modules/ 12 | 13 | # misc 14 | /coverage/ 15 | !.* 16 | .*/ 17 | .eslintcache 18 | 19 | # ember-try 20 | /.node_modules.ember-try/ 21 | /bower.json.ember-try 22 | /package.json.ember-try 23 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | ecmaVersion: 2018, 8 | sourceType: 'module', 9 | ecmaFeatures: { 10 | legacyDecorators: true, 11 | }, 12 | }, 13 | plugins: ['ember'], 14 | extends: [ 15 | 'eslint:recommended', 16 | 'plugin:ember/recommended', 17 | 'plugin:prettier/recommended', 18 | ], 19 | env: { 20 | browser: true, 21 | }, 22 | rules: {}, 23 | overrides: [ 24 | // node files 25 | { 26 | files: [ 27 | './.eslintrc.js', 28 | './.prettierrc.js', 29 | './.template-lintrc.js', 30 | './ember-cli-build.js', 31 | './index.js', 32 | './testem.js', 33 | './blueprints/*/index.js', 34 | './config/**/*.js', 35 | './tests/dummy/config/**/*.js', 36 | ], 37 | parserOptions: { 38 | sourceType: 'script', 39 | }, 40 | env: { 41 | browser: false, 42 | node: true, 43 | }, 44 | plugins: ['node'], 45 | extends: ['plugin:node/recommended'], 46 | }, 47 | { 48 | // Test files: 49 | files: ['tests/**/*-test.{js,ts}'], 50 | extends: ['plugin:qunit/recommended'], 51 | }, 52 | ], 53 | }; 54 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - master 8 | pull_request: {} 9 | 10 | jobs: 11 | test: 12 | name: 'Tests' 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Install Node 18 | uses: actions/setup-node@v2 19 | with: 20 | node-version: 12.x 21 | cache: yarn 22 | - name: Install Dependencies 23 | run: yarn install --frozen-lockfile 24 | - name: Lint 25 | run: yarn lint 26 | - name: Run Tests 27 | run: yarn test:ember 28 | 29 | floating: 30 | name: 'Floating Dependencies' 31 | runs-on: ubuntu-latest 32 | 33 | steps: 34 | - uses: actions/checkout@v2 35 | - uses: actions/setup-node@v2 36 | with: 37 | node-version: 12.x 38 | cache: yarn 39 | - name: Install Dependencies 40 | run: yarn install --no-lockfile 41 | - name: Run Tests 42 | run: yarn test:ember 43 | 44 | try-scenarios: 45 | name: ${{ matrix.try-scenario }} 46 | runs-on: ubuntu-latest 47 | needs: 'test' 48 | 49 | strategy: 50 | fail-fast: true 51 | matrix: 52 | try-scenario: 53 | - ember-lts-3.12 54 | - ember-lts-3.24 55 | - ember-release 56 | - ember-beta 57 | - ember-canary 58 | - ember-classic 59 | - ember-default-with-jquery 60 | - embroider-safe 61 | - embroider-optimized 62 | 63 | steps: 64 | - uses: actions/checkout@v2 65 | - name: Install Node 66 | uses: actions/setup-node@v2 67 | with: 68 | node-version: 12.x 69 | cache: yarn 70 | - name: Install Dependencies 71 | run: yarn install --frozen-lockfile 72 | - name: Run Tests 73 | run: ./node_modules/.bin/ember try:one ${{ matrix.try-scenario }} 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist/ 5 | /tmp/ 6 | 7 | # dependencies 8 | /bower_components/ 9 | /node_modules/ 10 | 11 | # misc 12 | /.env* 13 | /.pnp* 14 | /.sass-cache 15 | /.eslintcache 16 | /connect.lock 17 | /coverage/ 18 | /libpeerconnection.log 19 | /npm-debug.log* 20 | /testem.log 21 | /yarn-error.log 22 | 23 | # ember-try 24 | /.node_modules.ember-try/ 25 | /bower.json.ember-try 26 | /package.json.ember-try 27 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist/ 3 | /tmp/ 4 | 5 | # dependencies 6 | /bower_components/ 7 | 8 | # misc 9 | /.bowerrc 10 | /.editorconfig 11 | /.ember-cli 12 | /.env* 13 | /.eslintcache 14 | /.eslintignore 15 | /.eslintrc.js 16 | /.git/ 17 | /.gitignore 18 | /.prettierignore 19 | /.prettierrc.js 20 | /.template-lintrc.js 21 | /.travis.yml 22 | /.watchmanconfig 23 | /bower.json 24 | /config/ember-try.js 25 | /CONTRIBUTING.md 26 | /ember-cli-build.js 27 | /testem.js 28 | /tests/ 29 | /yarn-error.log 30 | /yarn.lock 31 | .gitkeep 32 | 33 | # ember-try 34 | /.node_modules.ember-try/ 35 | /bower.json.ember-try 36 | /package.json.ember-try 37 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | /vendor/ 4 | 5 | # compiled output 6 | /dist/ 7 | /tmp/ 8 | 9 | # dependencies 10 | /bower_components/ 11 | /node_modules/ 12 | 13 | # misc 14 | /coverage/ 15 | !.* 16 | .eslintcache 17 | 18 | # ember-try 19 | /.node_modules.ember-try/ 20 | /bower.json.ember-try 21 | /package.json.ember-try 22 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | singleQuote: true, 5 | }; 6 | -------------------------------------------------------------------------------- /.template-lintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: 'recommended', 5 | }; 6 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 1.0.1 2 | - BUGFIX: fix warning about nonexistent reexport by @Windvis. 3 | 4 | # 1.0.0 5 | 6 | - BREAKING: Drop support for ember < 3.12 7 | - INTERNAL: update style to Octane idioms by @ncoquelet 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How To Contribute 2 | 3 | ## Installation 4 | 5 | * `git clone ` 6 | * `cd ember-root-url` 7 | * `yarn install` 8 | 9 | ## Linting 10 | 11 | * `yarn lint` 12 | * `yarn lint:fix` 13 | 14 | ## Running tests 15 | 16 | * `ember test` – Runs the test suite on the current Ember version 17 | * `ember test --server` – Runs the test suite in "watch mode" 18 | * `ember try:each` – Runs the test suite against multiple Ember versions 19 | 20 | ## Running the dummy application 21 | 22 | * `ember serve` 23 | * Visit the dummy application at [http://localhost:4200](http://localhost:4200). 24 | 25 | For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/). 26 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ember-root-url 2 | ============================================================================== 3 | 4 | This addon provides the `root-url` helper: 5 | 6 | ```hbs 7 | 8 | ``` 9 | 10 | It's purpose is to make it easy to express a URL relative to your application's rootURL. 11 | 12 | Explanation 13 | ------------------------------------------------------------------------------ 14 | 15 | Because Ember apps handle their own routing, they need to know their own rootURL. This is configured in your `config/environment.js`. 16 | 17 | If your app includes some assets, those assets will also be available under the rootURL. 18 | 19 | If you want a portable way to refer to those assets, you need to construct their URLs relative to rootURL. Otherwise the links can break if you deploy your app under a new rootURL. 20 | 21 | 22 | 23 | 24 | 25 | Compatibility 26 | ------------------------------------------------------------------------------ 27 | 28 | * Ember.js v3.12 or above 29 | * Ember CLI v3.12 or above 30 | * Node.js v12 or above 31 | 32 | 33 | Installation 34 | ------------------------------------------------------------------------------ 35 | 36 | ``` 37 | ember install ember-root-url 38 | ``` 39 | 40 | 41 | Usage 42 | ------------------------------------------------------------------------------ 43 | 44 | If you have an image in your app's `public/images/hello.png`, you can link to it like: 45 | 46 | ```hbs 47 | 48 | ``` 49 | 50 | Assuming you are using the default `rootURL` of `/`, it will render like: 51 | 52 | ```hbs 53 | 54 | ``` 55 | 56 | And if you have a customized rootURL of "/my-app", it will render like 57 | 58 | ```hbs 59 | 60 | ``` 61 | 62 | Of course it's fine to pass any value, it doesn't need to be a literal: 63 | 64 | ```hbs 65 | 66 | ``` 67 | 68 | You can also build root-relative URLs in JavaScript using `service:root-url`: 69 | 70 | ```js 71 | export default MyComponent extends Component { 72 | rootUrl: service(), 73 | 74 | @computed 75 | get helloUrl() { 76 | return this.rootUrl.build('images/hello.png') 77 | } 78 | } 79 | ``` 80 | 81 | 82 | Contributing 83 | ------------------------------------------------------------------------------ 84 | 85 | See the [Contributing](CONTRIBUTING.md) guide for details. 86 | 87 | 88 | License 89 | ------------------------------------------------------------------------------ 90 | 91 | This project is licensed under the [MIT License](LICENSE.md). 92 | -------------------------------------------------------------------------------- /addon/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/addon/.gitkeep -------------------------------------------------------------------------------- /addon/helpers/root-url.js: -------------------------------------------------------------------------------- 1 | import Helper from '@ember/component/helper'; 2 | import { inject as service } from '@ember/service'; 3 | 4 | export default class RootUrl extends Helper { 5 | @service rootUrl; 6 | 7 | compute([relativeURL]) { 8 | return this.rootUrl.build(relativeURL); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /addon/services/root-url.js: -------------------------------------------------------------------------------- 1 | import { getOwner } from '@ember/application'; 2 | import Service from '@ember/service'; 3 | 4 | export default class RootUrlService extends Service { 5 | build(relativeURL) { 6 | let ENV = getOwner(this).resolveRegistration('config:environment'); 7 | return `${ENV.rootURL}${relativeURL.replace(/^\//, '')}`; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /app/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/app/.gitkeep -------------------------------------------------------------------------------- /app/helpers/root-url.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-root-url/helpers/root-url'; 2 | -------------------------------------------------------------------------------- /app/services/root-url.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-root-url/services/root-url'; 2 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup'); 5 | 6 | module.exports = async function () { 7 | return { 8 | useYarn: true, 9 | scenarios: [ 10 | { 11 | name: 'ember-lts-3.12', 12 | npm: { 13 | devDependencies: { 14 | 'ember-source': '~3.12.0', 15 | }, 16 | }, 17 | }, 18 | { 19 | name: 'ember-lts-3.24', 20 | npm: { 21 | devDependencies: { 22 | 'ember-source': '~3.24.3', 23 | }, 24 | }, 25 | }, 26 | { 27 | name: 'ember-release', 28 | npm: { 29 | devDependencies: { 30 | 'ember-source': await getChannelURL('release'), 31 | }, 32 | }, 33 | }, 34 | { 35 | name: 'ember-beta', 36 | npm: { 37 | devDependencies: { 38 | 'ember-source': await getChannelURL('beta'), 39 | }, 40 | }, 41 | }, 42 | { 43 | name: 'ember-canary', 44 | npm: { 45 | devDependencies: { 46 | 'ember-source': await getChannelURL('canary'), 47 | }, 48 | }, 49 | }, 50 | { 51 | name: 'ember-default-with-jquery', 52 | env: { 53 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 54 | 'jquery-integration': true, 55 | }), 56 | }, 57 | npm: { 58 | devDependencies: { 59 | '@ember/jquery': '^1.1.0', 60 | }, 61 | }, 62 | }, 63 | { 64 | name: 'ember-classic', 65 | env: { 66 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 67 | 'application-template-wrapper': true, 68 | 'default-async-observers': false, 69 | 'template-only-glimmer-components': false, 70 | }), 71 | }, 72 | npm: { 73 | ember: { 74 | edition: 'classic', 75 | }, 76 | }, 77 | }, 78 | embroiderSafe(), 79 | embroiderOptimized(), 80 | ], 81 | }; 82 | }; 83 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function (/* environment, appConfig */) { 4 | return {}; 5 | }; 6 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function (defaults) { 6 | let app = new EmberAddon(defaults, { 7 | // Add options here 8 | }); 9 | 10 | /* 11 | This build file specifies the options for the dummy test app of this 12 | addon, located in `/tests/dummy` 13 | This build file does *not* influence how the addon or the app using it 14 | behave. You most likely want to be modifying `./index.js` or app's build file 15 | */ 16 | 17 | const { maybeEmbroider } = require('@embroider/test-setup'); 18 | return maybeEmbroider(app, { 19 | skipBabel: [ 20 | { 21 | package: 'qunit', 22 | }, 23 | ], 24 | }); 25 | }; 26 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | name: require('./package').name, 5 | }; 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-root-url", 3 | "version": "1.0.1", 4 | "description": "A template helper to keep your URLs relative to the app's rootURL", 5 | "keywords": [ 6 | "ember-addon", 7 | "rootURL", 8 | "root", 9 | "url", 10 | "helper", 11 | "relative", 12 | "asset" 13 | ], 14 | "license": "MIT", 15 | "author": "Edward Faulkner ", 16 | "directories": { 17 | "doc": "doc", 18 | "test": "tests" 19 | }, 20 | "repository": "https://github.com/ef4/ember-root-url", 21 | "scripts": { 22 | "build": "ember build --environment=production", 23 | "lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"", 24 | "lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix", 25 | "lint:hbs": "ember-template-lint .", 26 | "lint:hbs:fix": "ember-template-lint . --fix", 27 | "lint:js": "eslint . --cache", 28 | "lint:js:fix": "eslint . --fix", 29 | "start": "ember serve", 30 | "test": "npm-run-all lint test:*", 31 | "test:ember": "ember test", 32 | "test:ember-compatibility": "ember try:each" 33 | }, 34 | "dependencies": { 35 | "ember-cli-babel": "^7.26.6", 36 | "ember-cli-htmlbars": "^5.7.1" 37 | }, 38 | "devDependencies": { 39 | "@ember/optional-features": "^2.0.0", 40 | "@ember/test-helpers": "^2.4.2", 41 | "@embroider/test-setup": "^0.43.5", 42 | "@glimmer/component": "^1.0.4", 43 | "@glimmer/tracking": "^1.0.4", 44 | "babel-eslint": "^10.1.0", 45 | "broccoli-asset-rev": "^3.0.0", 46 | "ember-auto-import": "^2.0.0", 47 | "ember-cli": "~3.28.1", 48 | "ember-cli-dependency-checker": "^3.2.0", 49 | "ember-cli-inject-live-reload": "^2.1.0", 50 | "ember-cli-sri": "^2.1.1", 51 | "ember-cli-terser": "^4.0.2", 52 | "ember-disable-prototype-extensions": "^1.1.3", 53 | "ember-export-application-global": "^2.0.1", 54 | "ember-load-initializers": "^2.1.2", 55 | "ember-maybe-import-regenerator": "^0.1.6", 56 | "ember-page-title": "^6.2.2", 57 | "ember-qunit": "^5.1.4", 58 | "ember-resolver": "^8.0.2", 59 | "ember-source": "~3.28.0", 60 | "ember-source-channel-url": "^3.0.0", 61 | "ember-template-lint": "^3.6.0", 62 | "ember-try": "^1.4.0", 63 | "eslint": "^7.32.0", 64 | "eslint-config-prettier": "^8.3.0", 65 | "eslint-plugin-ember": "^10.5.4", 66 | "eslint-plugin-node": "^11.1.0", 67 | "eslint-plugin-prettier": "^3.4.1", 68 | "eslint-plugin-qunit": "^6.2.0", 69 | "loader.js": "^4.7.0", 70 | "npm-run-all": "^4.1.5", 71 | "prettier": "^2.3.2", 72 | "qunit": "^2.16.0", 73 | "qunit-dom": "^1.6.0", 74 | "webpack": "^5.0.0" 75 | }, 76 | "engines": { 77 | "node": "12.* || 14.* || >= 16" 78 | }, 79 | "ember": { 80 | "edition": "octane" 81 | }, 82 | "ember-addon": { 83 | "configPath": "tests/dummy/config" 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | test_page: 'tests/index.html?hidepassed', 5 | disable_watching: true, 6 | launch_in_ci: ['Chrome'], 7 | launch_in_dev: ['Chrome'], 8 | browser_start_timeout: 120, 9 | browser_args: { 10 | Chrome: { 11 | ci: [ 12 | // --no-sandbox is needed when running Chrome inside a container 13 | process.env.CI ? '--no-sandbox' : null, 14 | '--headless', 15 | '--disable-dev-shm-usage', 16 | '--disable-software-rasterizer', 17 | '--mute-audio', 18 | '--remote-debugging-port=0', 19 | '--window-size=1440,900', 20 | ].filter(Boolean), 21 | }, 22 | }, 23 | }; 24 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | import Resolver from 'ember-resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from 'dummy/config/environment'; 5 | 6 | export default class App extends Application { 7 | modulePrefix = config.modulePrefix; 8 | podModulePrefix = config.podModulePrefix; 9 | Resolver = Resolver; 10 | } 11 | 12 | loadInitializers(App, config.modulePrefix); 13 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/tests/dummy/app/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/tests/dummy/app/controllers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/tests/dummy/app/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | {{content-for "head-footer"}} 16 | 17 | 18 | {{content-for "body"}} 19 | 20 | 21 | 22 | 23 | {{content-for "body-footer"}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/tests/dummy/app/models/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import EmberRouter from '@ember/routing/router'; 2 | import config from 'dummy/config/environment'; 3 | 4 | export default class Router extends EmberRouter { 5 | location = config.locationType; 6 | rootURL = config.rootURL; 7 | } 8 | 9 | Router.map(function () {}); 10 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/tests/dummy/app/routes/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/tests/dummy/app/styles/app.css -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 | {{page-title 'Dummy'}} 2 |

3 | ember-root-url 4 |

5 |

6 | You should see two copies of our example image, even if you run this 7 | app under a new rootURL: 8 |

9 | exemple 10 | exemple -------------------------------------------------------------------------------- /tests/dummy/config/ember-cli-update.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0.0", 3 | "packages": [ 4 | { 5 | "name": "ember-cli", 6 | "version": "3.28.1", 7 | "blueprints": [ 8 | { 9 | "name": "addon", 10 | "outputRepo": "https://github.com/ember-cli/ember-addon-output", 11 | "codemodsSource": "ember-addon-codemods-manifest@1", 12 | "isBaseBlueprint": true, 13 | "options": [ 14 | "--yarn", 15 | "--no-welcome" 16 | ] 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function (environment) { 4 | let ENV = { 5 | modulePrefix: 'dummy', 6 | environment, 7 | rootURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true 13 | }, 14 | EXTEND_PROTOTYPES: { 15 | // Prevent Ember Data from overriding Date.parse. 16 | Date: false, 17 | }, 18 | }, 19 | 20 | APP: { 21 | // Here you can pass flags/options to your application instance 22 | // when it is created 23 | }, 24 | }; 25 | 26 | if (environment === 'development') { 27 | // ENV.APP.LOG_RESOLVER = true; 28 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 29 | // ENV.APP.LOG_TRANSITIONS = true; 30 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 31 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 32 | } 33 | 34 | if (environment === 'test') { 35 | // Testem prefers this... 36 | ENV.locationType = 'none'; 37 | 38 | // keep test console output quieter 39 | ENV.APP.LOG_ACTIVE_GENERATION = false; 40 | ENV.APP.LOG_VIEW_LOOKUPS = false; 41 | 42 | ENV.APP.rootElement = '#ember-testing'; 43 | ENV.APP.autoboot = false; 44 | } 45 | 46 | if (environment === 'production') { 47 | // here you can enable a production-specific feature 48 | } 49 | 50 | return ENV; 51 | }; 52 | -------------------------------------------------------------------------------- /tests/dummy/config/optional-features.json: -------------------------------------------------------------------------------- 1 | { 2 | "application-template-wrapper": false, 3 | "default-async-observers": true, 4 | "jquery-integration": false, 5 | "template-only-glimmer-components": true 6 | } 7 | -------------------------------------------------------------------------------- /tests/dummy/config/targets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const browsers = [ 4 | 'last 1 Chrome versions', 5 | 'last 1 Firefox versions', 6 | 'last 1 Safari versions', 7 | ]; 8 | 9 | // Ember's browser support policy is changing, and IE11 support will end in 10 | // v4.0 onwards. 11 | // 12 | // See https://deprecations.emberjs.com/v3.x#toc_3-0-browser-support-policy 13 | // 14 | // If you need IE11 support on a version of Ember that still offers support 15 | // for it, uncomment the code block below. 16 | // 17 | // const isCI = Boolean(process.env.CI); 18 | // const isProduction = process.env.EMBER_ENV === 'production'; 19 | // 20 | // if (isCI || isProduction) { 21 | // browsers.push('ie 11'); 22 | // } 23 | 24 | module.exports = { 25 | browsers, 26 | }; 27 | -------------------------------------------------------------------------------- /tests/dummy/public/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/tests/dummy/public/example.png -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/tests/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy Tests 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 |
25 |
26 |
27 |
28 |
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {{content-for "body-footer"}} 38 | {{content-for "test-body-footer"}} 39 | 40 | 41 | -------------------------------------------------------------------------------- /tests/integration/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/tests/integration/.gitkeep -------------------------------------------------------------------------------- /tests/integration/helpers/root-url-test.js: -------------------------------------------------------------------------------- 1 | import { module, test } from 'qunit'; 2 | import { setupRenderingTest } from 'ember-qunit'; 3 | import { render } from '@ember/test-helpers'; 4 | import hbs from 'htmlbars-inline-precompile'; 5 | 6 | module('Integration | Helper | root-url', function (hooks) { 7 | setupRenderingTest(hooks); 8 | 9 | test('it accepts urls with a leading slash', async function (assert) { 10 | this.set('inputValue', '/1234'); 11 | await render(hbs`{{root-url this.inputValue}}`); 12 | assert.equal(this.element.textContent.trim(), '/1234'); 13 | }); 14 | 15 | test('it accepts urls witout a leading slash', async function (assert) { 16 | this.set('inputValue', '1234'); 17 | await render(hbs`{{root-url this.inputValue}}`); 18 | assert.equal(this.element.textContent.trim(), '/1234'); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import Application from 'dummy/app'; 2 | import config from 'dummy/config/environment'; 3 | import * as QUnit from 'qunit'; 4 | import { setApplication } from '@ember/test-helpers'; 5 | import { setup } from 'qunit-dom'; 6 | import { start } from 'ember-qunit'; 7 | 8 | setApplication(Application.create(config.APP)); 9 | 10 | setup(QUnit.assert); 11 | 12 | start(); 13 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/tests/unit/.gitkeep -------------------------------------------------------------------------------- /tests/unit/services/root-url-test.js: -------------------------------------------------------------------------------- 1 | import { module, test } from 'qunit'; 2 | import { setupTest } from 'ember-qunit'; 3 | 4 | module('RootURL Service', function (hooks) { 5 | setupTest(hooks); 6 | 7 | test("build prepends the application's rootURL", function (assert) { 8 | const service = this.owner.lookup('service:root-url'); 9 | assert.equal( 10 | service.build('/some/path.png'), 11 | '/some/path.png', 12 | 'root-relative' 13 | ); 14 | assert.equal( 15 | service.build('another/path.gif'), 16 | '/another/path.gif', 17 | 'relative' 18 | ); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ef4/ember-root-url/0145214e49b773267a9b8bf8d6b7f6bbfe855487/vendor/.gitkeep --------------------------------------------------------------------------------